Odata Wcf Web API按日期时间偏移量筛选
我目前正在使用WCF Web API Preview 5,并尝试筛选LastModifiedDate大于或等于提供的datetimeoffset的用户列表:Odata Wcf Web API按日期时间偏移量筛选,odata,wcf-web-api,Odata,Wcf Web Api,我目前正在使用WCF Web API Preview 5,并尝试筛选LastModifiedDate大于或等于提供的datetimeoffset的用户列表: http://api.myapp.com/users?$filter=LastModifiedDate ge datetimeoffset'2011-06-01T14:03:00+00:00Z' 然而,我得到的只是一个错误,说: Microsoft.ApplicationServer.Query.ParseException: '.'
http://api.myapp.com/users?$filter=LastModifiedDate ge datetimeoffset'2011-06-01T14:03:00+00:00Z'
然而,我得到的只是一个错误,说:
Microsoft.ApplicationServer.Query.ParseException: '.' or '(' expected (at index 34)
由于此筛选器返回请求的用户,因此筛选似乎工作正常
http://api.myapp.com/users?$filter=UserId eq 1
-- XML Response
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfUser xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<User>
<ExtensionData />
<CreateDate />
<CreatedById>1</CreatedById>
<IsDeleted>false</IsDeleted>
<LastModifiedById>1</LastModifiedById>
<LastModifiedDate />
<Name>Joe</Name>
<UserId>1</UserId>
</User>
</ArrayOfUser>
-- JSON Response
[
{
"CreateDate":
{
"DateTime":"\/Date(1306481778297)\/",
"OffsetMinutes":0
},
"CreatedById":1,
"IsDeleted":false,
"LastModifiedById":1,
"LastModifiedDate":
{
"DateTime":"\/Date(1306936979717)\/",
"OffsetMinutes":0
},
"Name":"Joe",
"UserId":1
}
]
http://api.myapp.com/users?$filter=UserId等式1
--XML响应
1.
假的
1.
乔
1.
--JSON响应
[
{
“CreateDate”:
{
“日期时间”:“\/日期(1306481778297)\/”,
“偏移分钟数”:0
},
“CreatedById”:1,
“IsDeleted”:错误,
“LastModifiedById”:1,
“LastModifiedDate”:
{
“日期时间”:“\/日期(1306936979717)\/”,
“偏移分钟数”:0
},
“姓名”:“乔”,
“用户ID”:1
}
]
只是不能让它与DateTimeOffset过滤器一起工作,所以我是否创建了错误的过滤器?还是有其他原因在起作用?你试过了吗
http://api.myapp.com/users?$filter=LastModifiedDate ge datetimeoffset('2011-06-01T14:03:00+00:00Z')
或
感谢Alexander,我确实尝试了这两种方法,认为第一种方法可以为我提供oData函数,但我仍然得到一个错误,即“String”不能转换为“DateTimeOffset”类型。因此,我认为该功能不起作用或不可用。然后我尝试了你的第二个例子和我在问题中提供的例子。然而,在我的问题中,这两个查询都提供了错误消息。昨天Glenn发布时,我将框架升级为Preview 6,但这并没有改变任何东西,这让我认为它与过滤器查询有关。我认为提交一个bug是有意义的。Ok done,当我收到响应时将更新问题。作为需要归档的错误报告的答案接受。
http://api.myapp.com/users?$filter=LastModifiedDate ge (datetimeoffset'2011-06-01T14:03:00+00:00Z')