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

The Archive Base Latest Questions

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

I have a class base on my map, it inherited two new classes <?xml

  • 0

I have a class base on my map, it inherited two new classes

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Business" namespace="Business.Test">
<class name="BaseExample" table="base_example" abstract="true" discriminator-value="0">
    <id name="Id" column="id" type="Int64" unsaved-value="0">
        <generator class="native"/>
    </id>
    <discriminator column="domain" type="Int16" not-null="true" force="true" />
    ....
    ....
</class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Business"   namespace="Business.Test">

<subclass name="Example1" extends="BaseExample" discriminator-value="1">
....
....
</subclass>
</hibernate-mapping>

everything works fine, but if I ask for that field, for example:

var Clients = ClientFactory.GetAll().Where(c => c.UserData.BaseExample.Domain == 1);

throw this exception: Exception Message: could not resolve property: Domain of: Business.Entities.BaseExample

how can tell if it is of one class or another?

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

    Discriminators are meant to be used behind-the-scenes from NHibernate (see Rippo’s example). The idea is that you query the class and the appropriate discriminator from that class’s mapping is injected into the query.

    However, if for some reason you need that information in a property it is valid to include it as a property. That means

    <class name="BaseExample" table="base_example" abstract="true" discriminator-value="0">
        <id name="Id" column="id" type="Int64" unsaved-value="0">
            <generator class="native"/>
        </id>
        <discriminator column="domain" type="Int16" not-null="true" force="true" />
        <property name="domain" column="domain" type="Int16" update="false" insert="false" />
        ....
        ....
    </class>
    

    it is important that you declare the property as readonly (update="false" insert="false") since this is a column managed completely by nhibernate.

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

Sidebar

Related Questions

I have two tables. With Sqlalchemy, I map them to two classes: class A(base):
I have some base class A , and some number of inherited classes: class
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC
I have a base class where I derive several classes. I have another class
I have these classes: class Base { ... private: std::vector<X> v; }; class Derived
I have an abstract base class called Curve . There are three classes that
Let's assume I have three classes that are subclasses of a base class: public
If I have a polymorphic base class called Base as well as classes Derived1
I have one base class which holds a map for function pointers like this
I have a Base class and two childs (A:Base and B:Base), and I want

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.