I need help for a dynamic where clause over relational tables (one to many) in LinqToSql.
User select conditions from page. (there is 4 input that u
Depends on how dynamic you want it to be - as others already suggested the System.Linq.Dynamic namespace adds some neat functionality for composing queries where entities/members (tables/columns) involved are not known at design time. In this case it sounds like the entities and members involved are already known and you just need to alternate between different fields as you where clause criteria. Here's an example of that:
from cust in dc.Customer
join ord in dc.Order on cust.CustomerID equals ord.CustomerID
where (companyName == null || cust.CompanyName == companyName)
and (companyTitle == null || cust.CompanyTitle == companyTitle)
and (orderDate == null || ord.OrderDate == orderDate)
and (shipCity == null || ord.ShipCity == shipCity)
select new {cust, ord}