我目前正在使用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: '.' 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
}
]
无法使用DateTimeOffset过滤器,所以我是否错误地创建了过滤器?或者还有别的东西在玩吗?
答案 0 :(得分:2)
你试过吗
http://api.myapp.com/users?$filter=LastModifiedDate ge datetimeoffset('2011-06-01T14:03:00+00:00Z')
或
http://api.myapp.com/users?$filter=LastModifiedDate ge (datetimeoffset'2011-06-01T14:03:00+00:00Z')