entity framework - WebApi OData: $filter 'any' or 'all' query not working -


first, using asp.net webapi tutorials i've created basic apicontroller exposes entity framework model through odata. service works return json odata $filter queries.

when perform odata $filter queries include "any" or "all" queryies on multi-value property throws odataexception

here's odata query i'm trying use

~/api/blogs?$filter=any(tags,name+eq+'csharp')

my apicontroller looks 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 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' not have property 'name' 

as can see, have nothing out of ordinary in code , should work fine. possible "any" , "all" queryies aren't supported yet in microsoft asp.net web api odata?

your needs changed bit. try this:

~/api/blogs?$filter=tags/any(tag: tag/name eq 'csharp') 

this assuming tags returns collection of tags, not single tag have above.

$inlinecount supported out of box odata format. wrote extensively here:

web api odata inlinecount not working

the short answer can working other formats code looks this:

public pageresult<customer> get(odataqueryoptions<customer> queryoptions) {     iqueryable results = queryoptions.applyto(_customers.asqueryable());     return new pageresult<customer>(results ienumerable<customer>, request.getnextpagelink(), request.getinlinecount()); } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -