Well, what we don’t know is your model structure or what LINQ provider you’re using. However, in general, with a well-structured domain model, you’d simply do this:
db.Posts.Where(p => p.Comments.Count() > x)
Given an integer variable x
, this should evaluate to the collection of Post
objects in which there are more than x
comments.
solved Linq query to get all posts with more than X comments