'is there a way to query OData with a linq query
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.
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jason |
