Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 542359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:26:18+00:00 2026-05-13T10:26:18+00:00

I am trying to learn MVC and nHibernate by creating a simple blog application.

  • 0

I am trying to learn MVC and nHibernate by creating a simple blog application.

I have a posts table and a comments table. Each post can have multiple comments. Now in my view I have to display the details of the post and the number of comments.

I tried the below code

(from post in DbContext.Posts
where post.ScheduledDate <= DateTime.Now && post.Approved == true
orderby post.ScheduledDate descending
select new { Post = post, CommentCount = post.Comments.Count() }).Take(10);

This returns the below SQL:

SELECT top 10 count(comments1_.Id) as y0_ 
FROM Posts this_ 
left outer join Comments comments1_ 
         on this_.Id=comments1_.PostId 
WHERE (this_.ScheduledDate <= '2009-12-29' and this_.Approved = 1) 
ORDER BY this_.ScheduledDate desc

And obviously throws a sql exception that group by is not used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:26:18+00:00Added an answer on May 13, 2026 at 10:26 am

    Looks like this was some weird issue with the NHContrib LINQ provider. I upgrade to version 3 of nHibernate and the new LINQ provider seems to be working perfectly well for the same query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn Microsoft MVC 2, and have in that case found
I am trying to learn ASP.NET MVC and I hit this problem: I have
Well I am trying to learn the java MVC pattern, but I can't understand
I'm trying to learn Spring MVC 3.0 and I made a simple web to
I'm trying to learn ASP.NET MVC, and I want to have menus highlighted on
I was trying to download some ASP.NET MVC Sample application to learn MVC. I
I am trying to learn ASP.net MVC 2 and I have created the DB
I am trying to learn about the Orchard MVC application. I see the following
I'm trying to learn MVC architecture for PHP. So I play with some simple
I'm trying to learn the MVC pattern, but each place say something different. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.