0

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

1
  • 1
    What about in get and set for the property? EF saves what the getter returns and use the setter to set the property value ... Commented Apr 7, 2014 at 19:21

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

nice, that would work, I'll probably create a template file to generate them since there are 600+ tables. FML

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.