Why does this work ?
var x = from p in db.People let oCount = p.Orders.Count select p;
And not this ?
var x = from p in db.People let oCount = Count(p) select p;
private int Count(DataContext.Order o)
{
return o.Count;
}
Why does this work ?
var x = from p in db.People let oCount = p.Orders.Count select p;
And not this ?
var x = from p in db.People let oCount = Count(p) select p;
private int Count(DataContext.Order o)
{
return o.Count;
}
LINQ to SQL "understands" p.Orders.Count
, but it can't look inside your method to work out what it means - it could be doing anything as far as LINQ to SQL is concerned.
In your first query, p.Orders.Count
is all represented in an expression tree which can be examined programmatically at execution time.