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

  • Home
  • SEARCH
  • 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 3497822
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:25:02+00:00 2026-05-18T12:25:02+00:00

How can I do this query with NHibernate select top 10 count(distinct classedition.createdby_id) as

  • 0

How can I do this query with NHibernate

select top 10 count(distinct classedition.createdby_id) as editions, class.id,
       class.name, class.createdon, class.createdby_id
from class 
inner join classedition on class.id = classedition.class_id
group by class.id, class.name, class.createdon, class.createdby_id
order by editions desc, class.createdon desc

I’m using NHibernate 3. I tried to do it with the new Linq provider without success. I don’t care about the way of doing it as long as it produce the exact sql query above. I would prefer writing a strongly typed query, without magic string if possible.

I’m new to NHibernate so this question may be simple.

Here is a little more info

I use Fluent NHibernate with AutoMappings. The C# classes are very simple:

public  class Class
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
    public virtual DateTime CreatedOn { get; set; }
}

public class ClassEdition
{
    public virtual int Id { get; set; }
    public virtual Class Class { get; set; }
    public virtual User CreatedBy { get; set; }
}

public class User
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
}
  • 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-18T12:25:03+00:00Added an answer on May 18, 2026 at 12:25 pm

    I finally resolved the problem by using a View.

    I don’t want to be rude, but it seems like the NHibernate community is more inclined to argue on the way I ask a question then responding to the question itself. See the comments for Diego Mijelshon’s answer. I received the same reproaches (about using unit tests) on nhusers (Google Groups): http://groups.google.com/group/nhusers/browse_thread/thread/4c74269aefb918fc

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

Sidebar

Related Questions

Can someone tell what is wrong with this query? sqltext = SELECT utyp, count(*)
Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP
I have this hql query, which works perfect: select m from Media m join
Take this query as an example: select * from publisher where id not in
If this is possible, please provide a sample query or two so I can
I read this article where Ayende states NHibernate can (compared to EF 4): Collection
My scenario is this: I have a base NHibernate query to run of the
I have the following scenario in nHibernate: <class name=TestApp.Components.User,TestApp.Components table=Users> <id name=Id column=UserId type=Int32
I have a SQL query I'm having trouble creating using NHibernate Criteria: SELECT ID,
Can this be done by setting a property? I'd prefer that approach then to

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.