'Is there a ODATA query to linq where expression (ODATA to Linq )

Basically,

I would like to convert odata query expression "$filter", "itemID eq 1" to where(w=>w.itemID==1)

Is there a ready library for this operation? Otherwise I need to code it by using DynamicLinq classes and linqKit.



Solution 1:[1]

You can use following NuGet package to apply filter: https://www.nuget.org/packages/Community.OData.Linq

Code sample would be:

using System.Linq;
using Community.OData.Linq;

// dataSet in this example - any IQuerable<T> 
Sample[] filterResult = dataSet.OData().Filter("Id eq 2 or Name eq 'name3'").ToArray();

Currently supported: filter and orderby in v4 format

Solution 2:[2]

You Can use Microsoft.Rest.Azure.OData

string filter = new ODataQuery(x => x.itemID == 1).Filter;

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 Ihar Yakimush
Solution 2 Mohammed Altaher