I have following structure:
public class Customer
{
public int ID { get; set; }
public List<Order> Orders { get; set; }
}
public class Order
{
public int ID { get; set; }
public int ProductID { get set; }
}
I need to get the collection of customers that ordered ProductID = 6. What would the fluent style LINQ look like?
I tried below with no luck:
var customers = allCustomers.SelectMany(c => c.Orders.Select(o => o.ProductID.Equals(6))).ToArray();
var customers = allCustomers.Where(c => c.Orders.Any(o => o.ProductID == 6));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With