Skip to content

Querying an Edm.Date property does not serialize correctly #1016

@jnanneng

Description

@jnanneng

Given the following entity definition:

 <Key>
      <PropertyRef Name="Id"/>
 </Key>
 <Property Name="Id" Type="Edm.Guid" Nullable="false"/>
 <Property Name="Value" Type="Edm.Date" Nullable="false"/>
 <Property Name="Value2" Type="Edm.Date"/>

Querying for a specific entity's data returns an Edm.Date as expected:
=> .../UnitTestDateTable(86e978ba-61d1-11e7-8501-3cd92b73d5f7)
{
@odata.context: ".../$metadata#UnitTestDateTable/$entity",
Id: "86e978ba-61d1-11e7-8501-3cd92b73d5f7",
Value: "1941-12-07",
Value2: "1943-09-19"
}

However when querying for an Edm.Date property (Value) does not return as expected:
=> .../UnitTestDateTable(86e978ba-61d1-11e7-8501-3cd92b73d5f7)/Value
{
@odata.context: ".../$metadata#UnitTestDateTable(86e978ba-61d1-11e7-8501-3cd92b73d5f7)/Value",
value: "1941-12-07T00:00:00-06:00"
}

Expected "1941-12-07" but actually returns "1941-12-07T00:00:00-06:00" [looks like a DateTimeOffset value].

This is further a problem when using the ODataMessageReader to "ReadProperty()" which throws an exception:

An exception of type 'Microsoft.OData.Core.ODataException' occurred in Microsoft.OData.Core.dll but was not handled in user code

Additional information: Cannot convert the literal '1941-12-07T00:00:00-06:00' to the expected type 'Edm.Date'.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions