Filtering a list based on an object member
HI Im trying to figure out how to filter my list based on a class member, but i dont know how
Im trying to display IQueryable with filter say this is my Request
public class Request
{
[Column] public int RequestID { get; set; }
[Column] public string Requester { get; set; }
[Column] public DateTime DepartureTime { get; set; }
}
I want to pass a dictionary to my controller so the controller can process the filter and display it.
But how do I define the dictionary
//This isn't even the right syntax
filter = new Dictionary<What_to_put_here,What_to_put_here>
{
{Request.Requester, "Mario"},
{Request.DepartureTime, 05/05/2011 11:00PM}
}
so that later I can do something like
repo.Requests.where(filter.key == filter.value)
Is there any better ways to do it开发者_JAVA百科? or is this even possible?
you can filter like
repo.Requests.Where(filter=>filter.RequestID == 2);
and
repo.Requests.Where(filter=>filter.RequestID < 2 && filter.DepartureTime < DateTime.Now);
精彩评论