Reputation: 6884
I have a table full of orders, where each order has a state (for example: failed, denied, pending, cancelled or success
)
How can I write a dynamic query to return orders, by state, where I'm passing one or more states?
ie something like all failed, denied or cancelled orders:
IQueryable<MyType> query = from o in Model.Orders
where o.OrderStatus == ("Failed" || "Denied" || "Cancelled")
select o;
Upvotes: 2
Views: 216
Reputation: 39898
You can try to use the Contains method
string[] status = {"Failed", "Denied", "Cancelled"};
IQueryable<MyType> query = from o in Model.Orders
where status.Contains(o.OrderStatus)
select o;
Upvotes: 4