Hi,
I have an 3-layered project, so that all Linq-Querys himself are in the DAL. Now I have a filter function implemented in the Desig-Layer and want easily filter there, but how?
Business.UserHandling uh = new Business.UserHandling();
List<DAL.Benutzer> users = uh.GetUserOverview();
gridUserOverview.AutoGenerateColumns = false;
gridUserOverview.DataSource = users;
gridUserOverview.DataBind();
How can I user something like "users = users.Where("bla = 1")"?
I tried:
Business.UserHandling uh = new Business.UserHandling();
List<DAL.Benutzer> users = uh.GetUserOverview();
var filters = new Dictionary<string, object>();
filters.Add(Request.QueryString["value"], Request.QueryString["text"]);
users = users.Where(user => filters.All(filter => user.GetType().GetProperty(filter.Key).GetValue(user, null) == filter.Value)).ToList();
gridUserOverview.AutoGenerateColumns = false;
gridUserOverview.DataSource = users;
gridUserOverview.DataBind();
But it fails... I filtered on "UserID = 1", I have 2 Users, the filter should be filter 1 of these 2. But the return is 0 users.