I'm using [EnableQuery]
and returning an IQueryable
from my api controller like this:
[HttpGet]
[EnableQuery]
public IQueryable<Category> Get()
{
return getCategories().AsQueryable();
}
Is it possible to consume this odata url using linq
, e.g. something like:
var res = await getOdata("Category").Where(item => item.Size > 100).ToArrayAsync();
does something like this exist ? I could only find examples of odata api's being built and consumed via string parameters but no linq.
CodePudding user response:
There are mainly 2 ways to add Query Options to a DataServiceQuery
- Using AddQueryOption method.
- Using strongly typed C# LINQ query methods.
So you can query OData with LINQ query. For more details, you can check below official doc.