我有一个清单orders。 我想orders根据一组订单状态进行选择。
orders
所以本质上select orders where order.StatusCode in ("A", "B", "C")
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;
您的状态代码也是一个集合,因此请使用Contains:
Contains
var allowedStatus = new[]{ "A", "B", "C" }; var filteredOrders = orders.Order.Where(o => allowedStatus.Contains(o.StatusCode));
或在查询语法中:
var filteredOrders = from order in orders.Order where allowedStatus.Contains(order.StatusCode) select order;