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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:00:21+00:00 2026-06-11T20:00:21+00:00

public class Store { public virtual prop1 { get; set;} public virtual int RegionID

  • 0
public class Store
{
public virtual prop1 { get; set;}
public virtual int RegionID { get; set;}
public virtual Region Region { get; set;
}

public class Region
{
  public virtual int RegionID { get; set;}
}

In the end my sql should look like

select * from store inner join region on store.regionid = region.regionid

How can I get the below to work to attain the inner join above.

Session.QueryOver<Store>()
                .JoinQueryOver<Region>(s => s.Region)
  • 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-11T20:00:23+00:00Added an answer on June 11, 2026 at 8:00 pm

    To attain the inner join, you must setup the relationship between the Store entity and the Region entity in your NHibernate mappings.

    You cannot specify the keys to join-on using the QueryOver API.

    Your classes should look similar to this:

    public class Region
    {
      public virtual int RegionID { get; set;}
      public virtual IList<Store> Stores { get; set; }
    }
    
    public class Store
    {
        public virtual int StoreId { get; set;}
        public virtual Region Region { get; set; }
    }
    

    And your mappings should look similar to this:

    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
      <class xmlns="urn:nhibernate-mapping-2.2" name="YourNameSpace.Region, YourNameSpace" table="Region">
        <id name="RegionID">
          <column name="RegionID" />
          <generator class="identity" />
        </id>
        <bag cascade="all" inverse="true" name="Stores">
          <key>
            <column name="RegionID" />
          </key>
          <one-to-many class="YourNameSpace.Store, YourNameSpace" />
        </bag>
      </class>
    </hibernate-mapping>
    
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
      <class xmlns="urn:nhibernate-mapping-2.2" name="YourNameSpace.Store, YourNameSpace" table="Store">
        <id name="StoreID">
          <column name="StoreID" />
          <generator class="identity" />
        </id>
    
        <many-to-one class="YourNameSpace.Region, YourNameSpace" name="Region">
          <column name="RegionId" />
        </many-to-one>
      </class>
    </hibernate-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following entity public class Employee { public virtual int Id {get;set;}
public class MyClass { public string MyProperty{ get; set; } Now, I would like
public class User { public long Id {get;set;} [References(typeof(City))] public long CityId {get;set;} [????]
Imagine I have this class: Class Foo { public Bar b1 { get; set;
My Model looks like like this public class User { public int ID {
Take the following scenario: Public Class Store Public Overridable Property Areas As List(Of Area)
I extended Application to store my global variables: public class MyApp extends Application{ private
public class A { private A(int param1, String param2) {} public static A createFromCursor(Cursor
Let's say I have a Rectangle class like so: class Rectangle { public: double
I would like to store a pointer to the main Game class in my

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.