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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:43:18+00:00 2026-05-19T01:43:18+00:00

I have a scenario where I have a base class as one entity, then

  • 0

I have a scenario where I have a base class as one entity, then another entity that derives from the other base class. Both have meaning in my domain and can be used separately.

public class MyBaseClass
{
    int ID { get; set; }
    string Name { get; set; }
}

public class MyChildClass
{
    string AdditionalField { get; set; }
}

I have both mapped using Fluent nHibernate using ClassMap like this:

public class MyBaseClassMap : ClassMap<MyBaseClass>
{
   Id("MyBaseClassID");
   Map(x => x.Name);
}

public class MyChildClassMap : SubclassMap<MyChildClass>
{
   Map(x => x.AdditionalField);
}

What is happening is when I try to fetch a copy of the base class, its using the mapping for the child class. Its as if it doesn’t know the the difference between the base and child class, or its choosing the wrong mapping for it. I confirmed this by watching the SQL statement and its joining to the child table and fetching the additional column. Any way to get it to use the right map?

  • 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-19T01:43:19+00:00Added an answer on May 19, 2026 at 1:43 am

    That’s the ‘nature’ of NHibernate.
    The behaviour you’re describing, is called ‘polymorphic queries’.

    Since MyChildClass is a MyBaseClass, the MyChildClass instances are retrieved as well.

    If you want to avoid this behaviour, you can maybe have a look at the answers in this topic. (I’ve never ‘disabled’ the polymorphic query ability).

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

Sidebar

Related Questions

I have a very simple scenario, using NHibernate: one abstract base class animal; two
I have a scenario where I need to upload a file from one web
Have this scenario: public class Base { public string Name; } public Class ClassA
We have a scenario where in if an entity exists between the source and
Let's say in some abstract ViewModel base-class I have a plain-old property as follows:
I have a class that my client uses to Get() a packet. The packet
i have code like below. Base is the base class and D1, D2, D3
I have a class Base. A and B extend Base. There is also a
I have a script that appends some rows to a table. One of the
I have created the POCO class and it's equivalent in edmx file (Category entity

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.