text:
Q: Linq query to get all posts with more than X comments I'm building a small blog application with asp mvc5.
I'm trying to add a search option that uses LINQ to SQL query.
my tables are like this:
Posts:PostID(int), Title(nvarchar), Body(nvarchar)

Comments:CommentID(int), Comment(nvarchar), PostID(int)

The PostID from the Comments table associates the comment object with a specific post.
I'm trying to write a query that given a number X will return all posts with X or more comments.
Is it possible to do in one query?
Thanks, David

A: 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.


• Limit very long distance driving. Stop at least every two hours for rest.
• Avoid the use of any kind of medicine during driving. According to researches, some medicines tend to take a person to drowsiness during driving.
• It is always better to have a companion and switch driving at regular intervals.
• Keep your eyes moving and check your mirrors often.


White tiltable recessed spotlight IP44 / 65 made of cast aluminum. Protected by an aluminum lid and pyrex glass. This bathroom lamp has an IP65 sealing class, spray-proof and dust-proof. Suitable for in the bathroom even above the shower.


Welcome to our best seller collection. We know what sells, and our instincts are never wrong, which is why our ladies wholesale clothing range hits the spot every time. But there are always the bright stars that fly off the shelves faster than the rest, so we've brought our best selling dresses, tops, jeans, skirts and shorts together in one place so you can find the best of the best.
When it comes to wholesale clothing, we know what sells. We've got the best ladies wholesale clothing in Manchester, and our best seller range features some of the hottest trends in the industry.
Every clothing collection has those select few bright stars that fly off the shelves faster than the rest, and we've brought them all together right here just for you. Browse our best selling dresses, tops, jeans, skirts and playsuits, all featuring the latest designs, styles and gorgeous prints that your customers will go crazy for.
At Inox clothing we've always got our finger on the pulse when it comes to fashion trends, anticipating new developments and making sure we pinpoint the styles that sell. With this expertise constantly working in the background, you can feel sure that all wholesale clothing you buy from us will be a hit.
Popular stock selling out fast? You can replenish your collection quickly with our same-day dispatch service, and our incredibly low prices mean you can keep coming back for more.