I'm trying to figure the best way to count number of child records inside a projection.
LinqSupportClasses : 2.6.9.220
ORSMSupportClasses: 2.6.9.305
Could you explain why the following does not work. I'm using adapter model.
var q = from c in metaData.Customer.WithPath(p=>p.Prefetch(c=>c.Orders))
select new
{
Name = c.ContactName,
NumOrders = c.Orders.Count //Count causes a problem
};
I found the following workaround, but I like the above syntax much better
var q = from c in metaData.Customer
select new
{
Name = c.ContactName,
NumOrders =
(from o in metaData.Orders
where o.CustomerId == c.CustomerId
select o).Count()
};
Thank you.