A
Andy
Suppose I have the following class which maps to a table:
public class People {
[Column( IsDbGenerated = true, IsPrimaryKey = true )]
public int PersonId { get; set; }
[Column]
public string FirstName { get; set; }
[Column]
public string LastName { get; set; }
[Column]
public DateTime? BirthDate { get; set; }
}
In the database all DateTimes MUST be stored in UTC. When the client
of the data layer gets the DateTime, it MUST be in LocalTime. To keep
easily forgotten code out of the business layer, I'd like to have a
way to specify when the BirthDate field is sent to the db,
ToUniversalTime is automatically called. Likewise, when getting the
BirthDate, ToLocalTime should be called.
Is there some where to hook into the Linq to Sql execution that would
allow me to do this translation?
Thanks
Andy
public class People {
[Column( IsDbGenerated = true, IsPrimaryKey = true )]
public int PersonId { get; set; }
[Column]
public string FirstName { get; set; }
[Column]
public string LastName { get; set; }
[Column]
public DateTime? BirthDate { get; set; }
}
In the database all DateTimes MUST be stored in UTC. When the client
of the data layer gets the DateTime, it MUST be in LocalTime. To keep
easily forgotten code out of the business layer, I'd like to have a
way to specify when the BirthDate field is sent to the db,
ToUniversalTime is automatically called. Likewise, when getting the
BirthDate, ToLocalTime should be called.
Is there some where to hook into the Linq to Sql execution that would
allow me to do this translation?
Thanks
Andy