Page 1 of 1

Mapping

Posted: Mon 07 Nov 2011 13:06
by babel1979
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 ?

Posted: Tue 08 Nov 2011 15:44
by StanislavK
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.