Is there any way to perform the following in one query? Something like...
em.Customers
.Select(c => new CustomerLite()
{
CustomerID = c.ID,
CustomerName = c.Name,
... etc ...
OrderCount = c.Orders.Count(),
Orders = c.Orders
.Select(o => new OrderLite()
{
OrderID = o.ID,
OrderDate = o.Date,
OrderProductCount = o.Products.Count,
... etc ...
})
});
CustomerLite and OrderLite are POCO entities and are intended to be lighter-weight versions of Customer and Order. I've tried countless ways of getting this (or similar) to work and I'm fairly convinced it's not possible. Everything works without issue until I attempt to pull the collection of OrderLite. I'm at the point that the only thing I can think to do is pull the CustomerLites and OrderLites in separate queries and add the OrderLites to the CustomerLites manually. Am I missing something obvious?
Edited by ken.nelson - 03-Dec-2010 at 6:17am