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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:37:26+00:00 2026-05-23T12:37:26+00:00

What I want to do is display a simple grid of data which contains

  • 0

What I want to do is display a simple grid of data which contains the entity data, and the aggregate data of its children. For example lets use a Order and line items. I want to display the order information, and the count of line items.

OrderID, OrderDate, NumOfLineItems

Now normally in SQL you can do it many ways. But this is the only way I could think of that might work when translating to NHibernate.

SELECT o.OrderID, OrderDate, NumOfLineItems
FROM #Orders o
INNER JOIN
(SELECT o2.OrderID, COUNT(*) As NumOfLineItems FROM #LineItems l
INNER JOIN #Orders o2 ON o2.OrderID = l.OrderID
WHERE UserID = 1 GROUP BY o2.OrderID) t1 ON o.OrderID = t1.OrderID
WHERE UserID = 1

I know there are other ways, but I’m trying to think of ways that NHibernate will allow me to do using QueryOver syntax. I do not want to use derived columns. I am trying to avoid writing SQL.

For my entities I have an Order entity, and an AggregatedOrder entity, which will be my DTO in this case, and I plan to use the transformer aliastobean to copy the data into it.

I just have absolutely no idea how to figure this out.

All I have so far:

        QueryOver<LineItem> x = QueryOver.Of<LineItem>()
            .SelectList(p => p .SelectCount(l => l.Id).WithAlias(() => itemAlias.NumOfLineItems))
            .JoinQueryOver<Order>(l => l.Order)
            .Where(o => o.UserID == userID)


        var y = session.QueryOver<Listing>()
            .JoinQueryOver<Bid>(x); // no idea whats going on here
  • 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-23T12:37:27+00:00Added an answer on May 23, 2026 at 12:37 pm

    Given:

    public class Order
    {
        public virtual int OrderId {get; set;}
        public virtual DateTime OrderDate {get; set;}
        public virtual IList<LineItem> LineItems {get; set;}
    }
    public class LineItem
    {
        public virtual int Id {get; set;}
        public virtual string Description {get; set;}
    }
    

    To query a projection of Order + Aggregated LineItem using QueryOver API you can do the following:

    OrderDto orderDto = null;
    LineItem items = null;
    var results = session.QueryOver<Order>()
         .JoinAlias(o => o.LineItems, () => items)
         .Select(Projections.ProjectionList()
          .Add(Projections.Property<Order>(o=>o.Id).WithAlias(()=>orderDto.OrderId))
          .Add(Projections.Property<Order>(o=>o.DateOrdered).WithAlias(()=>orderDto.DateOrdered))
          .Add(Projections.Count(()=> items.Id).WithAlias(()=>orderDto.ItemCount))
         )
         .TransformUsing(Transformers.AliasToBean<OrderDto>())
        .List<OrderDto>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to use facebook's fb:dialog tag to display a simple pop-up form for
I want to display data with level of detail, so i use a TreeView,
G'day! I want my WPF ComboBox to display some alternative text when its data-bound
I want to display a simple GIF image in a VBox using GTK+ from
I want to display a simple array of strings in a ListPopupWindow that is
I have a simple quiz application and I want display a nice timer /
I want to do a 'pop up image' using javascript to display a simple
I want display data from database in Listbox...Here is my code, It is not
I am currently developing an application in which I want to display a UserControl
My question is very simple - after data binding I want to set all

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.