Is there a better way to have conditional where clauses in LINQ equivalent to the following?
var doGroup=false; var doSub=true; var query= from mydata in Data_Details where ((doGroup && mydata.Group == "xxxx") || (doGroup==false)) && ((doSub && mydata.SubGroup == "yyyy") || (doSub==false)) select mydata; In the code above that works it will optionally include 'Group' and 'SubGroup' depending on whether doGroup and doSub are true are false.
I know when using method syntax you can simply keep appending code to the query in separate lines but I'd prefer to keep using query syntax.