Reputation: 323
I would like to sort a datagridview with multiple actions.
I explain myself: I've a dictionnary with a key and a value. The value is a string with ASC or DESC and I'd like to sort everything with this strategy:
string sort=String.Empty;
sort+=".OrderBy(c=>c.Value)"; ==> the first one in my list
foreach(var column in list)
{
if(column.Value=="DESC")
sort+=".ThenByDescending(c=>c.Value)";
if(column.Value=="ASC")
sort+=".ThenByAscending(c=>c.Value)";
}
List<Formule> list=ListFormules.Where(f=>f.Identificator==null)
==> It's my problem
I don't know how to change my string to work in my query. Have you an idea or a better way to do that?
Upvotes: 3
Views: 247