I currently have the below code to fetch data from my Entity framework model.
return db.Tasks.Where(t => (t.TaskStatuses.TaskStatusId.Equals(currentStatus) | currentStatus == -1) &
(t.Projects.ProjectId.Equals(projectId) | projectId == -1) &
(assignedToGuid == rnd | t.AssignedTo.UserId.Equals(assignedToGuid)));
I now want this to order the data, the function takes 2 stings OrderField and OrderDirection, is there anyway I can change my query to dynamically order by these variables?
Thanks
GavD,
The Dynamic Linq library will allow you to dynamically order your queries. See the following article for more information:
Dynamic Linq: Using the LINQ Dynamic Query Library
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx