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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:31:43+00:00 2026-05-13T16:31:43+00:00

Instinctively, I would say that this is impossible, as NHibernate needs to know some

  • 0

Instinctively, I would say that this is impossible, as NHibernate needs to know some mapping information on how to persist a given type. Thus, I encountered some situations in which I could use such a feature. For instance, through a named query or something like so. On the other hand, using a named query would require me to make an addition to the configuration file.

Let’s suppose we have an application interacting with some underlying datastore. This datastore is configured through the NHibernate configuration file. Then, I wish to have NHibernate load only a subset of an entity properties, from another subsystem to which my application shouldn’t need to interact much, so it is not worthy to define classes for this system, as I only need a fraction of this alien system’s information, let’s say three out of thirty-two data columns. For that matter, if I chose to load only those three columns let’s say for performance concerns, I would then use an anonymous type, perform the required action onto this information, then persist it back to the datastore. Now, it wouldn’t be of much interest to do so if I only had one entity to get loaded from the datastore, so let’s say I have about 75,000 rows to load into my process. I then shall consider this subset option very seriously!

What strategy should you choose in such situation, if you needed to persist these changes to a subset only of this entity’s properties?

FYI: I am asking because I must write specific rules of usage with NHibernate, such rules that even a beginner developer would even be able to use it without knowing too much about NHibernate, but only following the rules and guidance of the technical documents I have to produce.

Thanks in advance for any comments and answers.

  • 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-13T16:31:43+00:00Added an answer on May 13, 2026 at 4:31 pm

    There are two approaches to this.

    First, if you need to select entities and do not intend to persist them back to the DB, you can use select new HQL construct. Thus you’ll be able to specify which properties to load from the DB.

    Second approach is a bit more complicated and is better illustrated with the following example.

    Suppose you have Images table, which, naturally, contains images. It has Length, ContentType, CreatedOn, Content, Description and other columns.

    In some parts of your app you may want to just edit image metadata without actually displaying image itself. Therefore, for performance reasons you need to load just metadata portion. You will, however, will eventually be saving this to the DB, so the select new approach won’t work. What will work, though, is this:

    class ImageMetadata
    {
        public string ContentType { get; set; }
        public string Description { get; set; }
    
        // Etc
    }
    
    class Image : ImageMetadata
    {
        // To native English speakers out there: is it "Content" or "Contents"?
        public byte[] Content { get; set; }
    }
    

    Here, you’ll have to map both classes to the same underlying DB table and just load either ImageMetadata or whole Image depending on the situation.

    Granted, this doesn’t scale very well, but it can save you from lots of perf problems.

    As for 75 000 entities: ORMs are not for mass updates.

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

Sidebar

Related Questions

Would really appreciate some help with a search angine I'm trying to make for
This really should be easy, but I just can't work it out myself, the
Is there some way to enable Visual Studio 2008 to accept dropped files from
To start with some context, I'm so annoyed whenever I get on a Windows
I had a function that returned a random member of several groups in order
This isn't about a side-by-side technical comparison, rather about how to think in jQuery
This may be a stupid question, but here goes. I've seen several projects using
I have written two methods that take and return a string. One converts from
When writing code like this jsLint complains about implied globals: var Test = (function(){
My MIPS Assembly class required me to read in an expression of unknown size

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.