I have a fairly large data model that I want to expose using Web API OData using the OData V4 protocol.
The underlying data is stored in a SQL Server 2012 database.
This workarounds and the one from http://damienbod.wordpress.com/2014/06/16/web-api-and-odata-v4-crud-and-actions-part-3/, neither work. They work one way only, meaning that quering odata datetimeoffset with the filter command fails because it is not part of the model.
You can no longer filter or sort by these fields or get this error
/Aas/Activities?$top=11&$orderby=CreatedAt
Gives this error:
"code":"","message":"An error has occurred.","innererror":{
"message":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata.metadata=minimal'.","type":"System.InvalidOperationException","stacktrace":"","internalexception":{
"message":"The specified type member 'CreatedAt' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.","type":"System.NotSupportedException","stacktrace":"
But this works as it is addressed indirectly:
/Aas/AppUsers%28102%29/AppUserActivities?$expand=Case&$filter=%28Reminder%20ne%20null%20and%20IsComplete%20eq%20null%29&$top=15&$orderby=Reminder&$count=true
Reminder and Iscomplete are date and datetiem from activity through AppUserActivities.
This is wierd that that works. Does anyone have a solution?
I connect to MySQL. There is not a datetimeoffset.
And everyone wonders why no one wants to develop for Microsoft technologies.