Starting here:
public class Customer
{
public int CustomerID { get; set; }
public string CustomerName { get; set; }
public IList<Order> Orders { get; set; }
}
public class Order
{
public int OrderID { get; set; }
public int CustomerID { get; set; }
}
What would be the linq query that you write to retrieve all Orders from all Customers?
Something to the effect of:
IList<Order> orders = new List<Order>();
foreach (Customer c in Customers)
{
orders.Union(c.Orders);
}
I tried the following but it throws an "nhibernate collection was not an association" exception:
var orders = from c in Customers
select c.Orders;
I know I'm missing something, but I can't find a way to achieve this in linq.