How to add a where clause to Entity Framework query

asp.net asp.net-core c# entity-framework-6

Question

I have been trying to figure out how to add a Where clause to this. I need

Where OrderHeader.OrderStatus = "NEW"

Any help is a appreciated.

using (context)
{
    var orderData = context.OrderHeaders
                           .Join(context.OrderLines,
                                 OrderHeader => OrderHeader.Id,
                                 OrderLine => OrderLine.OrderHeaderId,
                                 (OrderHeader, OrderLine) => new
                                               {
                                                   Id = OrderHeader.Id
                                               }).ToList()

    foreach (var order in orderData)
    {
        CreateOrder(order.Id, context);
    }
}
1
-1
2/6/2020 4:54:27 PM

Accepted Answer

context.OrderHeaders
    .Where(o => o.OrderStatus == "NEW")
    .Join(...
4
2/6/2020 3:56:51 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow