c# - Linq most efficient method -
I need to use the Linq statement as the following
var data = Db.tbl1 Ou (w = & gt; client eids == client end and source = source == source); I have a dropdown from which I get the source dropdown values as follows:
All NewsPage web < P> The thing is that there are valid values for newsletters and web sources. Not everyone does all mean that a record can be newspapper or web If they select all, then how do I modify whitesource such as newspapers or web of all the tools I mentioned below I can do 2 different questions, but not:
if (source == "all") {var data = db.tbl1. Where (w = & gt; Customer ID == clientid); } And {var data = db.tbl1. Where (w = & gt; Customer ID == Client end and source == source); } I like doing this in 1 query because I have a query that is more complex than the ones shown above.
Thank you in advance
@mattammo reply is acceptable, but I like I broke them out a bit IMO is a little more readable.
var data = db.tbl1.Where (w = & gt; Customer ID == client); If (source! = "All") data = data Where (w = & gt; W. source == source);
Comments
Post a Comment