I'm creating a WCF service whose result is not a strict OData feed (for complicated reasons, business strategy, etc). In addition, the format of the URL is slightly different from OData although most of its features are very similar.
How I can tran开发者_C百科sform the URI in a Linq Expression tree?.
Thanks in advance.
Have a look at Linq2Rest - https://bitbucket.org/jjrdk/linq2rest. It parses an OData query into a LINQ expression, and the other way around. It's available on Nuget as well.
Currently this functionality is not exposed on its own. And writing it yourself is rather complex (depends on what type of queries you need to support and on your model). Is it really necessary to deviate from the OData protocol? Maybe what you need to do can be achieved through other means.
You can use following nuget package: https://www.nuget.org/packages/Community.OData.Linq
It allows to use OData text query parameters in linq expresson for any IQuerable without ASP.NET dependency
var result = query.OData().Filter("Id eq 1 or Name eq 'n3'").OrderBy("Name desc").ToArray();
精彩评论