DateTimeOffsets in Entity Model
Posted: Thu 27 Oct 2011 16:31
I've got a Postgres database that contains a number of tables. There are 2 or more "TimeStamp with TimeZone" columns in each table. When Entity Developer builds the classes for these tables, it uses the C# DateTime data type for the properties that correspond to the "TimeStamp with Timezone" columns.
In our C# code, we want to use the DateTimeOffset type, as this preserves the time zone information. (If you use a DateTime to receive the data from the database, it is converted to local time AND THE TIMEZONE IS LOST. We want to keep the time zone offset until we display it, at which time we'll convert to local time.)
How do I get the model to use this data type? Do I have to edit the individual properties?
Tony
P.S.
I tried editing one of the DateTime properties & set it to DateTimeOffset. This didn't work as I got the following message:
How do I make this work?
In our C# code, we want to use the DateTimeOffset type, as this preserves the time zone information. (If you use a DateTime to receive the data from the database, it is converted to local time AND THE TIMEZONE IS LOST. We want to keep the time zone offset until we display it, at which time we'll convert to local time.)
How do I get the model to use this data type? Do I have to edit the individual properties?
Tony
P.S.
I tried editing one of the DateTime properties & set it to DateTimeOffset. This didn't work as I got the following message:
Code: Select all
Member Mapping specified is not valid.
The type 'Edm.DateTimeOffset[Nullable=False,DefaultValue=,Precision=]'
of member 'AlarmTime' in type 'LPRCore.CarSystem.Alarm' is not compatible with 'Devart.Data.PostgreSql.timestamptz[Nullable=False,DefaultValue=,Precision=0]'
of member 'AlarmTime' in type 'LPRCore.CarSystem.Store.Alarms'.