我有一个OData v4 WebAPI 2终点:
http://windows-10:8888/Incident
此终点需要支持对DateTime字段进行过滤:
http://windows-10:8888/Incident?$filter=REPORTEDDATE gt DateTimeOffset'2016-05-10%2016:01:53.000'
当我运行时,我收到此错误:
"The query specified in the URI is not valid.
Unrecognized 'Edm.String' literal 'DateTimeOffset'2016-05-10 16:01:53.000''
at '16' in 'REPORTEDDATE gt DateTimeOffset'2016-05-10 16:01:53.000''."
使用OData v4完成此类DateTime过滤的正确技巧是什么?
答案 0 :(得分:1)
根据规范,http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html部分5.1.1.6.1示例:
http://localhost:23890/People?$ expand = Trips($ filter = StartsAt%20eq%202014-01-01T01:00:00-08:00)或http://localhost:23890/People?$ expand = Trips($ filter = StartsAt%20eq%202014-01-01T01:00:00.000-08:00)或http://localhost:23890/People?$ expand = Trips($ filter = StartsAt%20eq%202014-01-01T01:00:00Z)
我已经验证了Web APi OData或REStier,这很有效。
答案 1 :(得分:0)
在此处找到正确的语法:celery
在我的例子中,语法是:
http://stackoverflow.com/questions/28586797/the-binary-operator-lessthan-is-not-defined-for-the-types-system-nullable1sys