var query = from C in db.clients
join O in db.orders on c.clientid equals O.clientid
join P in db.products on O.productid equals P.productid
select ne
Another method:
Expression> clientWhere = c => true;
Expression> orderWhere = o => true;
Expression> productWhere = p => true;
if (filterByClient)
{
clientWhere = c => c.ClientID == searchForClientID;
}
if (filterByProductName)
{
productName = p => p.ProductName == searchForProductNameString;
}
// other filter cases
var query = from C in db.clients.Where(clientWhere)
join O in db.orders.Where(orderWhere) on c.clientid equals O.clientid
join P in db.products.Where(productWhere) on O.productid equals P.productid
select new {C,O};