首先,使用ASP.NET WebApi教程創建了一個基本的ApiController that exposes an Entity Framework model through OData。該服務用於返回用於OData $過濾器查詢的json。
當我在一個多值屬性進行的OData $filter queries that include "any" or "all" queryies它拋出一個ODataException
這裏的OData的查詢我試圖使用
~/api/Blogs?$filter=any(Tags,Name+eq+'csharp')
我ApiController看起來是這樣的:
public class BlogController : ApiController
{
public BlogsController()
{
this.Entities = new BlogEntities();
}
public ContactEntities Entities { get; set; }
[Queryable(PageSize = 25, AllowedQueryOptions = AllowedQueryOptions.All)]
public IQueryable<Blog> Get()
{
return this.Entities.Blogs;
}
}
博客實體有這個合同
public Blog {
public Guid ID { get; set; }
public string Title { get; set; }
public Tag Tags { get; set; }
}
public Tag {
public Guid ID { get; set; }
public string Name { get; set; }
}
拋出的異常
ODataException: Type 'Blog' does not have a property 'Name'
正如你所看到的,我什麼都沒有了我的代碼,一切都普通的應該正常工作。 Microsoft ASP.NET Web API OData中是否有可能「any」和「all」查詢不被支持?
另一個值得注意的事情是,' $ inlinecount'odata選項被忽略。 – 2013-03-18 11:32:17