OT: Linq data massaging

OT: Linq data massaging

Old forum URL: forums.lhotka.net/forums/t/4393.aspx


ajj3085 posted on Friday, February 22, 2008

Hi,

Another OT post.. sorry..

In my current custom data layer, all entity properties are tagged with a FieldData attribute.  If the property is a DateTime or Nullable<DateTime>, the attribute will look at a property TimeStorageOption, which indicates how the datetime is handled.  The two options are LocalDate or UTC. 

If the entity is sending the datetime to the database and UTC is indicated, the the ToUniversalTime method is called on the date, so that the database will get the UTC time.

If the entity is receiving the datetime from the database, and UTC is indicated, it will call ToLocalTime on the value before loading it into the entity.

In this way, the BOs deal ONLY with local time, and the datalayer handles translating the datetimes between local and UTC time.  I'd like the ability to do something similar though linq.  Is there anyway to do some code injection or something to acomplish this?

Thanks
Andy

Copyright (c) Marimer LLC