且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

没有为类型'System.Nullable'1 [System.DateTime]'和'System.Nullable'1 [System.DateTimeOffset]'定义二进制运算符LessThan

更新时间:2023-09-10 09:22:16

此处的问题是,尽管Microsoft具有查看评论 ),OData V4不包括DateTime作为原始类型.这意味着您的过滤器仍然需要使用DateTimeOffset.

The issue here is that while Microsoft has partly added DateTime support (see comments), OData V4 doesn’t include DateTime as primitive type. This means that your filter still needs to use DateTimeOffset.

虽然不理想,但将DateTime强制转换为DateTimeOffset似乎可以解决问题.

While not ideal, casting the DateTime to a DateTimeOffset seems to solve the problem.

/OData/Person?$top=20&$filter=cast(DOB,'Edm.DateTimeOffset') eq 1972-11-20T00:00:00.000Z