按 DateTimeOffset 的 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: '.' 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 过滤器一起使用,所以我是否错误地创建了过滤器?或者还有其他的事情在起作用吗?
I am currently using WCF Web API Preview 5 and am trying to filter a list of users where the LastModifiedDate is greater than or equal to the provided datetimeoffset:
http://api.myapp.com/users?$filter=LastModifiedDate ge datetimeoffset'2011-06-01T14:03:00+00:00Z'
However all I am getting is an error saying:
Microsoft.ApplicationServer.Query.ParseException: '.' or '(' expected (at index 34)
The filtering seems to be working fine as this filter returns the requested user
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
}
]
Just cannot get it working with the DateTimeOffset filter so am I creating the filter incorrectly? Or is there something else at play?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你尝试过
还是
Did you try
or