How to get Web API OData v4 to use DateTime

前端 未结 12 1212
时光取名叫无心
时光取名叫无心 2020-12-02 14:50

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.

12条回答
  •  既然无缘
    2020-12-02 15:10

    An alternate solution is to patch the project so that DateTime is allowed again - that's what I did, you can get the code here if you want it:

    https://aspnetwebstack.codeplex.com/SourceControl/network/forks/johncrim/datetimefixes

    I also pushed a NuGet package to make it easy to use, you can obtain the package using the info here:

    http://www.nuget.org/packages/Patches.System.Web.OData/5.3.0-datetimefixes

    ... I don't know if it's ok for me to post a NuGet package containing a patched Microsoft library, I hope it's easier to ask forgiveness than permission.

    Note that the work item to officially restore the ability to use DateTime in OData 4 is tracked here: https://aspnetwebstack.codeplex.com/workitem/2072 Please vote for the issue if you'd like to see it; though it looks like it's scheduled for 5.4-beta, so it should be coming one of these days.

提交回复
热议问题