DateTime values fail in WCF query request

99 Views Asked by At

While trying to query an OData sevice through WCF Data Services I ended up with invalid values in the request for my DateTime fields.

Here's the code:

var query = context.ApplicationData.Where(ad => 
            ad.dateFrom == DateTime.MinValue &&
            ad.dateTo == DateTime.MaxValue);
DataServiceCollection<ApplicationData> data = new DataServiceCollection<ApplicationData>(context);
data.LoadAsync(query);

Here's what I get:

[MyODataService]/ApplicationData()?$filter=dateFrom%20eq%20datetime'0001-01-01T00%3A00%3A00'%20and%20dateTo%20eq%20datetime'9999-12-31T23%3A59%3A59.9999999'

instead of

dateFrom=datetime'0001-01-01T00:00:00',dateTo=datetime'9999-12-31T23:59:59'

The request fails. Anyone have any idea why this escaping occurs for the DateTime values?

0

There are 0 best solutions below