allow the user to create dynamic expressions using the GUI wizard

c# dynamic-linq expression-trees linq

Question

I want to create a gui panel or wizard where users may create their own conditions or expressions by leveraging the attributes of a highly typed object model. basically along these lines

Using or/and/foreach operands, the structure may be nested (LHS/RHS might include additional expressions), and coupled with other expressions.

For each sub-expression, I want to be able to verify that the types and values are right. The final query should ideally be an expression tree or a Linq query.

My intention is to allow people create their own basic procedures or tactics.

What approach would you recommend for dealing with expressions, and how would you go about developing a dynamic query?

I'm considering expressing the expressions as strings, like as

person.DateOfBirth > 1970 && person.Country != Country.Germany

and then construct the expanded linq query using the concatenation as a parameter..Where as outlined here. clause generated by the Dynamic LINQ library

If this approach has limits, may dynamically advanced expression be created?

What other options do you propose?

1
1
5/24/2011 12:21:19 AM

Popular Answer

Check out the PredicateBuilder class in the LINQKit project.

2
10/20/2011 10:17:06 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow