Does anyone know if it is possible to programmatically set the orderby and ascending/descending conditions within a Linq statement (such as passing in values from the method parameter
s list)?
For example, assuming that I am using the following example Linq statement:
IOrderedQueryable<Employees> hireQuery =
from emp in db.Employees
orderby emp.HireDate descending
select emp;
Is it possible to programmatically set the orderby line programmatically by passing in dynamic values for the orderby column and where the column will be ascending/descending, rather than hard-coding such values?
vs2005
Member
20 Points
5 Posts
Programmatically set the orderby and ascending/descending clause in a Linq statement
Sep 06, 2007 11:43 AM|LINK
Hi,
Does anyone know if it is possible to programmatically set the orderby and ascending/descending conditions within a Linq statement (such as passing in values from the method parameter
s list)?
For example, assuming that I am using the following example Linq statement:
IOrderedQueryable<Employees> hireQuery =
from emp in db.Employees
orderby emp.HireDate descending
select emp;
Is it possible to programmatically set the orderby line programmatically by passing in dynamic values for the orderby column and where the column will be ascending/descending, rather than hard-coding such values?
Thanks,
John
LINQ