I have a scenario where I only need to use the WHERE when necessary, otherwise I just want to run my LINQ query without this WHERE .
For example:
if string name = "";
var res = (from a in db.person select new() { Name = a.FullName, DOB = a.DOB }).ToList();
if string name = "satya";
var res = (from a in db.person where a.person.contains(name) select new() { Name = a.FullName, DOB = a.DOB }).ToList();
I know that for this we must write two queries separately, but without writing separate queries, how can we combine them into one query?
Satya pratap
source share