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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:53:00+00:00 2026-05-24T10:53:00+00:00

Well it all seems so simple and yet I can’t find the answer to

  • 0

Well it all seems so simple and yet I can’t find the answer to my problem.

Let’s say I have 2 tables TableA and TableB that can hold a single reference to a 3rd table:

TableA       TableB        TableC
ID           ID            ID
TableC_ID    TableC_ID     RandomDataC
RandomDataA  RandomDataB

Each are represented by the following classes:

public Class ClassA{
  public virtual int Id{get;set;}
  public virtual ClassC ObjAC{get;set;}
  ...
}

public Class ClassB{
  public virtual int Id{get;set;}
  public virtual ClassC ObjBC{get;set;}
  ...
}

public Class ClassC{
  public virtual int Id{get;set;}
  ...
}

As you can see ClassA and ClassB hold a single property called ClassC.

I’ve tried the following mapping (amongst others…)

 public Class ClassAMap : ClassMap<ClassA>{
    public ClassAMap(){
       Id(x => x.Id);
       HasOne(x => x.ObjAC).Cascade.All();
       ...
    }
 }

 public Class ClassBMap : ClassMap<ClassB>{
    public ClassBMap(){
       Id(x => x.Id);
       HasOne(x => x.ObjBC).Cascade.All();
       ...
    }
 }

 public Class ClassCMap : ClassMap<ClassC>{
    public ClassCMap(){
       Id(x => x.Id);
    }
 }

but the mapping is incorrect. I’ve tried ClassCMap to have a ReferencesAny but without success.

Please help…

  • 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-24T10:53:00+00:00Added an answer on May 24, 2026 at 10:53 am

    Try this:

    public Class ClassAMap : ClassMap<ClassA>{
        public ClassAMap(){
           Id(x => x.Id);
           References(x => x.ObjAC, "TableC_ID").Cascade.All();
           ...
        }
     }
    
     public Class ClassBMap : ClassMap<ClassB>{
        public ClassBMap(){
           Id(x => x.Id);
           References(x => x.ObjBC, "TableC_ID").Cascade.All();
           ...
        }
     }
    
     public Class ClassCMap : ClassMap<ClassC>{
        public ClassCMap(){
           Id(x => x.Id);
        }
     }
    

    You may also want to make sure the correct table names are being inferred. The issue is that HasOne maps to an entity based on the primary key of the table you’re mapping from.

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

Sidebar

Related Questions

This seems like it should be simple but I can't find anything yet. In
Well, it seems simple enough, but I can't find a way to add a
Well, this one seems quite simple, and it is. All you have to do
The dilemma below seems like a very easy problem to overcome, yet I can't
Seems like a simple problem: I have an SVN repo inside our firewall. I
I have an array of values all well within the range 0 - 63,
We have a Perl program that ran well on all Windows platforms so far.
I have seen the example here . All well and good and I understand
I have created a QDialog based app using Qt Creator and all is well
I've created a Django project, using a PostGIS backend, which all seems well as

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.