allow the user to create dynamic expressions using the GUI wizard

c# dynamic-linq expression-trees linq

Question

I want to build a gui panel/wizard where my application's users could build custom conditions/expressions using the properties of a strongly typed object model. Basically something like this.

The structure could be nested (LHS/RHS might consist of other expressions) and combined with other expressions using or/and/foreach operands.

I want to be able to check for correct types and values for each sub-expression. Ideally the final query should be a linq query or an expression tree.

My goal is to let users design their own strategies or simple workflows.

What type you would suggest for handling the expressions and what solution for creating the dynamic query?

I am thinking representing the expressions as strings e.g.

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

and then create the linq query using the concatenation as parameter in the extended .Where clause produced by the Dynamic LINQ library as described here.

Is it possible to create dynamically advanced expression or there are limitations on this solution?

What alternative solutions do you suggest?

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

Popular Answer

Check LINQKit project especially PredicateBuilder class.

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