I have various windows forms applications that contain various controls that build up custom group by and where clauses for my class methods.I am thinking to pass a collection structure of some kind in order for the methods to be able to build the group by's and the where clauses. Let's say a list containing the field and the value for the group by or where.Am I going to the right direction?Update:I dont have code yet but let me try to explain better:We have a form with 10 dropdownlists and a checkmark beside them.Also we have adatagrid on the form.Every dropdownlist corresponds to a field in a table.If a dropdownlist has its checkbox checked means that it must be part of the group by clause in the select statement.The value of the dropdownlist must be part of the where clause.*note: *  Another application could have different numbers of dropdownboxes and different corresponding fields.I want to create a common method that will retrieve data with user selectable group by and where clauses.So what i think is to pass to the method 2 lists.One with (fieldname, value) for the where clausesAnd one with (fieldname) for the group bydepending on the logic above...I hope this is more clear.
Which collection structure I should use for parametrical grouping ordering in c#?
c#
Have you considered using LINQ/ an expression-tree?  It seems exactly to match your problem, unless I've missed something.Whatever the detail of the particular collection-type, as long as it's enumerable, you can use all the benefits of LINQ.  You have the datasource of your gridview (or whatever the datasource is); you can then attach events to the check-boxes/ drop-downs that add/remove the where/group-by based on the binding that they have to the fields in the database.Personally, I'd also design the system without much regard to the persistence mechanism, you want an easily-understood abstraction model at each level, it is rare that the same model is appropriate in different layers.I'm assuming you're using at least C# 3.