开发者

Entity Framework 4 custom Data type

开发者 https://www.devze.com 2023-02-15 19:59 出处:网络
I am starting to use Entity Framework 4. assuming I can not change the database fields. I have a field DateAdded that is stored as YYYYMMD开发者_开发技巧D and I would like to have the entity.DateAdded

I am starting to use Entity Framework 4. assuming I can not change the database fields. I have a field DateAdded that is stored as YYYYMMD开发者_开发技巧D and I would like to have the entity.DateAdded as a DateTime type. It would make it much easier to work with.

Is there a way to do a custom column data type mapping? or any workarounds?


You could add an additional property in a partial class for the entity that wraps the "raw" property.

namespace TheNamespace
{

  public partial class TheEntity
  {
      public DateTime DateAdded 
      {
         get {  }
         set {  }
      }
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消