4.1 DateTime support
This sample will introduce how to support DateTime type in Web API OData V4.
Build DateTime Type
OData V4 doesn’t include DateTime as primitive type. Web API OData V4 uses DateTimeOffset to represent the DateTime. For example, if user defines a model as:
The metadata document for Customer entity type will be:
Time Zone Configuration
By Default, converting between DateTimeOffset and DateTime will lose the Time Zone information. Therefore, Web API provides a API to config the Time Zone information on server side. For example:
$filter DateTime
Since Web API OData 5.6, it supports to filter on DateTime type. For example:
$orderby DateTime
Since Web API OData 5.6, it supports to orderby on DateTime type. For example:
Thanks.