I have a list of orders
.
I want to select orders
based on a set of order statuses.
So essentially select orders where order.StatusCode in ("A", "B", "C")
// Filter the orders based on the order status
var filteredOrders = from order in orders.Order
where order.StatusCode.????????("A", "B", "C")
select order;
Your status-codes are also a collection, so use Contains
:
var allowedStatus = new[]{ "A", "B", "C" };
var filteredOrders = orders.Order.Where(o => allowedStatus.Contains(o.StatusCode));
or in query syntax:
var filteredOrders = from order in orders.Order
where allowedStatus.Contains(order.StatusCode)
select order;