First, using the ASP.NET WebApi tutorials I've created a basic ApiController that exposes an Entity Framework model through OData. The service works to return json for OData $filter queries.
When I perform OData $filter queries that include "any" or "all" queryies on a multi-value property it throws an ODataException
Here's the OData query I'm trying to use
~/api/Blogs?$filter=any(Tags,Name+eq+'csharp')
My ApiController looks like this:
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;
}
}
The Blog entity has this contract
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; }
}
The exception thrown
ODataException: Type 'Blog' does not have a property 'Name'
As you can see, I have nothing out of the ordinary in my code and everything should work fine. Is it possible that "any" and "all" queryies aren't supported yet in Microsoft ASP.NET Web API OData?