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 8510303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:39:55+00:00 2026-06-11T03:39:55+00:00

Trying to implement following queries in NHibernate QueryOver. SQL SELECT SUM(GrossChargeAmount) FROM Charges INNER

  • 0

Trying to implement following queries in NHibernate QueryOver.

SQL

SELECT
     SUM(GrossChargeAmount)
FROM Charges
INNER JOIN Account on Account.Chargekey = Charges.Chargekey

SELECT
     SUM(GrossChargeAmount),
     Account.AccountHolder
FROM Charges
INNER JOIN Account on Account.Chargekey = Charges.Chargekey
GROUP BY
     Account.AccountHolder

NHibernate:

var accountAlias = null;

var baseQuery = session.QueryOver<Charges>()
                .JoinAlias(c => c.Account, () => accountAlias)
                .SelectList(s => s.SelectSum(c => c.GrossChargeAmount))

I have code that constructs the baseQuery. I then, depending on method parameters will want to append the GROUP BY to the baseQuery like:

baseQuery.SelectList(s => s.GroupBy(() => accountAlias.AccountHolder)

This however ends up resetting projections on my baseQuery and essentially “overwritting” the initial projections ( .SelectList(s => s.SelectSum(c => c.GrossChargeAmount)) ). At this stage an execution of the query will not have any SUM() bu just the GROUP BY.

TLDR; How do I add projections to an Nhibernate QueryOver instance?

Last, but not least I’m running on NHibernate 2.0.50727

  • 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-06-11T03:39:57+00:00Added an answer on June 11, 2026 at 3:39 am

    try:

    baseQuery.SelectList(s => 
        s.SelectSum(c => c.GrossChargeAmount)
        .GroupBy(() => accountAlias.AccountHolder))
    

    you could also build up the expression passed in to SelectList if you prefer

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

Sidebar

Related Questions

How to implement following query of SQL in entity framework. SELECT * FROM Users
Trying to implement the following structure from c to use NSArray in objective-c: In
I am trying to implement following: How can I start a flash video from
I'm trying to implement PLINQ example but facing following problem My sequential queries are
I'm trying to implement a delegate class following Herb Sutter's Example . There is
i receive the following error when trying to implement auto-complete based on edismax type.
I'm trying to implement the example code of the following question by using opencv
I'm trying to implement XOR in javascript in the following way: // XOR validation
I'm trying to implement my own GenericIdentity implementation but keep receiving the following error
I'm trying to implement autocomplete for a textbox using the following code, but it's

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.