I'm attempting to create a dynamic Linq Library query to get data based on the following criteria: Customers with an order quantity larger than three and a ShipVia field equal to two.
Here is my tried-and-true syntax.
object objArr = new object; objArr = 1; IQueryable<Customer> test = db.Customers.Where("Orders.Count(ShipVia=2)", objArr);
IQueryable<Customer> test = db.Customers.Where("Orders.Any(ShipVia=2).Count()", objArr);
Both, however, are ineffective. Any returns true in the second question, hence it is incompatible with Count. Tell me how I can put this into practice.
The following is how your query should seem if you HAVE to use Dynamic Linq:
db.Customers.Where("Orders.Count(ShipVia == 2) > 3");