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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:43:54+00:00 2026-06-12T01:43:54+00:00

I am wondering since nhibernate has to make the entire object does it make

  • 0

I am wondering since nhibernate has to make the entire object does it make sense to do this?

Session.Query<Table>().Where(x => x.Id == id).Select(x => x.ColumnA).FirstOrDefault();

or would it be better to do this

Session.Query<Table>().Where(x => x.Id == id).FirstOrDefault();

I am trying to decide if I should make a separate method in my service layer to just return back ColumnA and have another method that returns all the fields back.

Or should I just have the one method that return all the fields like the second example would.

On one hand if I do it the first way then less data has to come back from the database especially when you know only one column will be used. On the other hand though it would suck if I need to it for each column.

 Session.Query<Table>().Where(x => x.Id == id).Select(x => x.ColumnB).FirstOrDefault();
 Session.Query<Table>().Where(x => x.Id == id).Select(x => x.ColumnC).FirstOrDefault();
  • 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-12T01:43:56+00:00Added an answer on June 12, 2026 at 1:43 am

    Selecting 1 property (or a number of them) is a projection. NHibernate definitely does support projections, and there are many situations in which it makes sense to use a projection.

    It depends on what problem you are trying to solve. If you do not know that there is a problem, then I would very much suggest not using projections to select single properties – it is much easier to work with the entities. However if you are facing a real performance issue, then you should analyze what’s happening and where the bottleneck is, and if after that analysis you discover that it really is because you’re selecting the whole entity instead of a single property of it, then by all means use a projection.

    Having said that, unless your entities have lots of properties and/or large data, it probably won’t make sense to project a single property. Also there will be some minor performance penalties such as duplicate query plans.

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

Sidebar

Related Questions

I am using PJAX https://github.com/defunkt/jquery-pjax and I was wondering since the whole page does
I'm wondering how to best tackle this, since what I have now works great
Since I've started programming in Java I have been wondering this (about a year
I've been wondering this for a while now; but especially more so since I've
Does a plugin exists for Python/Django into Dreamweaver? Just wondering since Dreamweaver is a
I know this question been asked a lot here, but just wondering since ICS
I'm wondering what's people using to correctly capitalize english strings since ''capitalize'' won't do
I was wondering why auto_increment is spelled with an underscore, since primary key not
Wondering what the best / good way of doing this would be in jQuery.
Since Java 7 is comming I was wondering how much time it would take

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.