(not tested)
from ld in meta.Location
select new
{
Id = ld.Id,
Title = ld.Name,
Events = from e in ld.EventName
let cnt = (from g in e.Game select g).Count()
where cnt > 0
select new
{
Id = e.Id,
Title = e.Name,
Count = cnt
}
}
but it could go wrong, as 'let' is a complex system.
(edit) I see this goes wrong as it misses the correlation filter between the nested queries. This is a bit of a complex situation as the 'let' burries the correlation filter (e.Game) into a different query. So forget 'let' in subqueries.
If you're worrying about the count executed twice, you can use any though I ran into a glitch there.
AAAARGG
Linq is the most frustrating piece of (#*$($@ I've ever worked with. You can't create solid code for it, as everything is connected to eachother, changing this invalidates that etc.
I reproduced the group by issue
What's weird is that I have many tests similar to this one which pass...
I've no idea what causes this but I saw where it occurs, stay tuned, for bugfix 328975239423 on the linq provider.