Suppose we have a list MyList
Then we can take in enumerable like below
IEnumerable<TestObject> query = MyList;
if (obj1 != null) {
query = query.Where(x => x.Id == obj1.ID);
}
if (obj2= null) {
query = query.Where(x => x.Number.Contains(obj2.Number));
}
if (obje3 != null) {
query = query.Where(x => x.Date == obj3.Date);
}
......
you can use many more
Finally we can convert in list, It basically reduce the complexcity
MYListView = query.ToList();
Then we can take in enumerable like below
IEnumerable<TestObject> query = MyList;
if (obj1 != null) {
query = query.Where(x => x.Id == obj1.ID);
}
if (obj2= null) {
query = query.Where(x => x.Number.Contains(obj2.Number));
}
if (obje3 != null) {
query = query.Where(x => x.Date == obj3.Date);
}
......
you can use many more
Finally we can convert in list, It basically reduce the complexcity
MYListView = query.ToList();
No comments:
Post a Comment