DateTimeUtcConverter Class
Namespace: Nucleus.Data.EntityFramework
Assembly: Nucleus.Data.EntityFramework.dll
The Entity Framework implementation for some database types do not store time zone information / set the DateTime.Kind to Unspecified. This causes problems when converting values to "Local". This converter ensures that date/time values are converted to UTC when they are saved to the database, and that when Date/time values are read from the database, the .Kind property is set to Utc.
Methods
ConvertFrom
(DateTime) Method
ConvertFrom (DateTime value)
Convert a value after reading it from the database
Returns
This function sets the "Kind" property to Utc without changing the value of the date/time, unless the value is DateTime.MinValue. If the value is DateTime.MinValue, the value is returned as-is.
ConvertTo
(DateTime) Method
ConvertTo (DateTime value)
Convert a value before writing it to the database.