我正在尝试过滤掉没有交付事件类型的订单,并且工作正常。
List<Order> matchingOrders = xyzContext.Orders.Where(
o => o.FacilityId == facility.MasterFacilityId
&& rxNumberList.Contains(o.RxNumber)
&& o.OrderEvents.All(oe => oe.EventType.Code != EventTypeCode.Delivered)).ToList();
之后我试图过滤具有事件类型的订单&#34; Ordered&#34;并且没有事件类型&#34;已交付&#34;而且我没有得到预期的结果。
List<Order> matchingOrders = xyzContext.Orders.Where(
o => o.FacilityId == facility.MasterFacilityId
&& rxNumberList.Contains(o.RxNumber)
&& o.OrderEvents.All(oe => oe.EventType.Code != EventTypeCode.Delivered && oe.EventType.Code == EventTypeCode.Ordered)).ToList();
答案 0 :(得分:0)
试试这个:
List<Order> matchingOrders = xyzContext.Orders.Where(
o => o.FacilityId == facility.MasterFacilityId
&& rxNumberList.Contains(o.RxNumber)
&& o.OrderEvents.All(oe => oe.EventType.Code != EventTypeCode.Delivered)
&& o.OrderEvents.Any(oe.EventType.Code == EventTypeCode.Ordered)).ToList();