How Do I Count Navigation Properties with Specific Values?

PostAlmostAnything 1 Reputation point
2021-09-23T10:08:52.65+00:00

I have a couple queries for counting everything with specific integer value. The first one works, but the second fails. The one that works is:

int paarisgold = Posts.Where((Posts p) => p.Cap == 3).Count();
if(paarisgold > 0)
{
Capnoindex = true;
}

The one that fails is:

int paarisgoldcomment = Comments.Count((Comments c) => c.PostNavigation.Cap == 3);
if (paarisgoldcomment > 0)
{
Capnoindex = true;
}

How do I change the second one so that I can count the number of c.PostNavigation.Cap that are equal to 3?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,187 questions
{count} votes