Parsing a string for a predicate

I am trying to work out a solution where, at run time, the procedure will parse the "string" and return the predicate. So far, I have found the DynamicLinq class (sample) that does the job.

I am wondering - is it possible to use OData lib for the same? Go to the structure line "odata" ("? Color = 'red' & param = foo") and get the Linq predicate?

+5
source share
2 answers

The ODataLib Contrib project contains a parser similar to what you are looking for. It has not yet created the LINQ predicate, it only produces an intermediate AST, but it can give you something to start with. See http://odata.codeplex.com/wikipage?title=ODataLib&referringTitle=Home (the library is available as source code on the code or as a nuget package http://nuget.org/packages/Microsoft.Data.OData.Contrib )

+1
source

Write a parser. This is actually quite simple if you analyze predicates for a small number of well-known types. In general, this probably requires reflection, which makes it a little more painful, but not canceled.

, , , . , , , , . YMMV.

, , - , ( ).

0

All Articles