我目前正在使用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过滤器一起使用,所以我是否错误地创建了过滤器?还是还有其他事情在玩?

有帮助吗?

解决方案

你试过了吗

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')
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top