I have an index which from a dictionary get the column string to order by in Linq
dict.Add(0, "seleccionado");
dict.Add(1, "IdPedido");
dict.Add(2, "FechaPedido");
dict.Add(3, "NSerie");
dict.Add(4, "Importe");
I have, too, a list of Orders and I need to get the order (DESC/ASC) when I click in the column of the field.
Mmy idea was to do the Linq in one line because I will pass two parameters: the string field to order and the direction (ASC/DESC).
How can I do it in Linq?
WHAT I TRIED:
pedidos.OrderBy(x => x.seleccionado);
seleccionado is the object of the class, but in my case I will give an string instead of the object field name.