Temporal Types
When using the Microsoft.Restier.Providers.EntityFramework provider, temporal types are now supported. The table below shows how Temporal Types map to SQL Types:| EF Type | SQL Type | Edm Type | Need ColumnAttribute? |
|---|---|---|---|
| System.DateTime | DateTime/DateTime2 | Edm.DateTimeOffset | Y |
| System.DateTimeOffset | DateTimeOffset | Edm.DateTimeOffset | N |
| System.DateTime | Date | Edm.Date | Y |
| System.TimeSpan | Time | Edm.TimeOfDay | Y |
| System.TimeSpan | Time | Edm.Duration | N |
Edm.DateTimeOffset
Suppose you have an entity classPerson, all the following code define Edm.DateTimeOffset properties in the
EDM model though the underlying SQL types are different (see the value of the TypeName property). You can see
Column attribute is optional here.
Edm.Date
The following code define anEdm.Date property in the EDM model.
Edm.Duration
The following code define anEdm.Duration property in the EDM model.
Edm.TimeOfDay
The following code define anEdm.TimeOfDay property in the EDM model. Please note that you MUST NOT omit the
ColumnTypeAttribute on a TimeSpan property otherwise it will be recognized as an Edm.Duration as described above.
ODataPayloadValueConverter, please now change to override
RestierPayloadValueConverter instead in order not to break the payload value conversion specialized for these
temporal types.