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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:33:31+00:00 2026-05-26T06:33:31+00:00

I am running into difficulty with the following nhibernate queryover query. I am probably

  • 0

I am running into difficulty with the following nhibernate queryover query. I am probably over-complicating things, but here is the problem:

  • I have an entity named AuctionStatistic that links to an auction (this is uni-directional and I do not have links from auctions back to statistics)
  • I would like to query the statistic table, find all auction IDs and pull back only those that meet a certain threshold – i.e. top 500 auctions by views
  • Once I’ve gotten the top X (in this example i’m hardcoding to 10000 views) I want to pull back the auction id and name. For this particular query I don’t need any of the data stored in the statistics table (though this is used elsewhere and is not redundant)

I figured I could use something like the following to get back just the auctions, but because I’m querying over AuctionStatistic it expects the selected value to be of type AuctionStatistic (or a list thereof)

var auctions = _session.QueryOver<AuctionStatistic>().Where(c => c.ViewCount > 10000).Fetch(x=>x.Auction).Eager.Select(x=>x.Auction);

Can anyone suggest a better way of doing this?

Thanks

JP

  • 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-26T06:33:32+00:00Added an answer on May 26, 2026 at 6:33 am

    Without bi-directional this is probably your best bet.

    Auction auctionAlias = null;
    AuctionDTO dto = null;
    
    var auctionDtos = _session.QueryOver<AuctionStatistic>()
        .Where(c => c.ViewCount > 10000)
        .JoinAlias(x => x.Auction, () => auctionAlias)
        .SelectList(list => list
            .Select(() => auctionAlias.id).WithAlias(() => dto.id)
            .Select(() => auctionAlias.name).WithAlias(() => dto.name))
        .TransformUsing(Transformers.AliasToBean<AuctionDTO>())
        .List<AuctionDTO>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running into some difficulty with the following query. SELECT maker, speed FROM
Running into a problem. I have a table defined to hold the values of
I'm running into difficulty when using the TableSorter jQuery plugin, if I have a
I'm running into difficulty setting up a new project into source control. I've imported
I'm running into significant difficulty getting my mapping file to work with a collection
I'm just getting into Factory Girl and I am running into a difficulty that
My application keeps running into Timeout Expired SqlExceptions. The thing is that this query
EDIT: I am basically running into the following documented issue . I am using
I am running into an error I am having trouble figuring out. I have
I'm running into problems implementing statuses for a model. This is probably due 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.