Reputation: 3
I have the following query which is returning the expected result but I'm having trouble accessing the Tickets count:
home.Projects = _db.Projects.Where(p => p.Users.Any(u => u.Id == userid)).Include(t => t.Tickets).ToList();
Upvotes: 0
Views: 49
Reputation: 50728
Use SelectMany:
home.Projects.SelectMany(i => i.Tickets).Count();
SelectMany compresses the one to many result into a singular result for this very purpose.
Upvotes: 2