Search code examples
ado.netwcf-data-services

Mark OData Property as Nullable when using ADO.NET Data Services Toolkit


We are using the ADO.NET Data Service Provider Toolkit to implement a custom OData service endpoint running inside SharePoint 2010 (using .NET 3.5).

It appears that by default Edm.DateTime is marked as Nullable="false" when generating the metadata for the service endpoint:

<Property Name="DATE" Type="Edm.DateTime" Nullable="false" />

Is there a way to change this setting for DateTime properties that can be NULL?

The same seems to be true for Edm.Boolean as well as some of the numeric types.


Solution

  • If the type of the property is Nullable, then so will the OData property.

    In this case instead of DateTime, the property needs to be DateTime? (nullable).