Example
from O in db.Orders
join C in db.Customers on C.Id equals O.CustID
Where O.ord_date == ( filter.OrderDate != null ? filter.OrderDate : o.ord_date) &&
c.Id == (filter.CustId != null ? filter.CustId : c.Id) &&
o.ProductId == ( filter.ProductId != null ? filter.ProductId : o.ProductID)
select new {o,c}
//select new {c.Name, C.JoinDate, O.Value, O.NoofLineItems }
When i trun on the profile it has a lot of case statements as i expect it to have. but i have lot more control on the condition what i put in in C# how can i exersise my control on the where condition and only put the where condition when filter is available for it
This will improve my quality of sql which goes to the db.
Kind regards
Vinay.
A general solution for this sort of issue is to use PredicateBuilder to dynamically construct the appropriate predicate.
First, build the predicate:
And then you query becomes: