Reputation: 473
I'm using Entity Framework 6.0 and creating an API with a database that is used by a custom made ORM by my company years ago.
In this old ORM: in the GET Mapper, some values in the Database were acted on before mapping it to the correct property. For example, some datetime properties were changed to the user timezone and then when being saved to the database, the opposite mapper changed the user timezone datetime to UTC to save in the Database.
HOW could this be done in EF 6? help PLEASE!!! a place where I can write custom logic on CERTAIN properties...not all before reading and saving
Upvotes: 0
Views: 1040
Reputation: 1479
What about using a partial class with properties that read/write from/to the database property?
public partial Entity
{
public DateTime UseThisDate
{
get { return ToUserLocalTime(BackendDate); }
set { BackendDate = ToUTC(value); }
}
}
The BackendDate
would be the column mapped to the database while UseThisDate
would be the property you'd use in your logic layer.
Upvotes: 1