Mapping

Mapping

Postby babel1979 » Mon 07 Nov 2011 13:06

Can I map propery to own data type ?

I have Oracle database and table Tmp in this table I have column name AAA and type DATE. How can I map this column to my own type DateTimeJulian ?
babel1979
 
Posts: 4
Joined: Mon 07 Nov 2011 12:10

Postby StanislavK » Tue 08 Nov 2011 15:44

LinqConnect does not support custom data types. You can, however, extend the entity classes (which are generated as partial) that use this custom type by implementing properties of this type. For example, it can be
Code: Select all
[The generated code in .designer.cs]
public partial class MyEntity() {
...
  public DateTime DateProperty {
  ...
  }
...
}

[Your code somewhere else]
public partial class MyEntity() {

  public DateTimeJulian DateInProperFormat {
    get {
      DateTimeJulian res = [convert 'this.DateProperty' to DateTimeJulian];
      return res;
    }
    set {
      DateTime res = [convert 'value' to DateTime];
      this.DateProperty = res;
    }
  }
}

JIC: it is important to use the public property ('DateProperty' in the sample) instead of the private field (e.g., '_DateProperty') to allow change tracking for the 'DateInProperFormat' property.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48


Return to LinqConnect (LINQ to SQL support)