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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:27:25+00:00 2026-06-15T21:27:25+00:00

Basically what i am trying to do is join two tables on foreign keys.

  • 0

Basically what i am trying to do is join two tables on foreign keys. I have this query:

        var result =
            _session.QueryOver(() => contentReferenceAlias)
                    .Inner.JoinAlias(() => contentReferenceAlias.ContentReference, () => contentLibrarySearchAlias.ContentReference)
                    .Where(() => contentReferenceAlias.ToLanguage.Id == languageId && contentReferenceAlias.ContentReference.Id == contentLibrarySearchAlias.ContentReference.Id)
                    .SelectList(list => list
                                            .Select(() => contentReferenceAlias.ContentReference)
                                            .Select(() => contentLibrarySearchAlias.ContentReference)
                                            .Select(() => contentReferenceAlias.ContentReference.Id).WithAlias(() => resultAlias.ContentReferenceId)
                                            .Select(() => contentReferenceAlias.ContentReference.Id).WithAlias(() => resultAlias.ContentReferenceId)
                                            .Select(() => contentReferenceAlias.OrderedFrom).WithAlia

The SQL im trying to recreate:

  SELECT A.OrderedFrom, C.LastOrdered, A.ContentReferenceId, B.Title FROM TranslationContentReference A
  INNER JOIN TranslationOrder C ON (A.TranslationOrderId = C.Id)
  INNER JOIN ContentLibrarySearch B ON (A.ContentReferenceId = b.ContentReferenceId)
  WHERE A.ToLanguageId = 'xxxx-xxxx-xxxx-xxxx-xxxx'
  • 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-15T21:27:27+00:00Added an answer on June 15, 2026 at 9:27 pm

    If I do understand your scenario correctly, join over man-in-the-middle (foreign key reference) cannot be achieved via QueryOver API. NHibernate needs to know pathes all the way down, So if there is no explicit mapping from TranslationContentReference through ContentReference to ContentLibrarySearch, then we cannot create correct JoinAliases.

    So, first option is to extend the man-in-the-middle object

    public class ContentReference
    {
        ...
        public virtual IList<TranslationContentReference> TranslationContentReference { get; set;}
        public virtual IList<ContentLibrarySearch> ContentLibrarySearch { get; set;}
    }
    

    Then we can navigate (create pathes)

    • from TranslationContentReference to ContentReference
    • from ContentReference to ContentLibrarySearch

    The second option, which is less NHibernate and more SQL, is to create ISQLQuery

    ISQLQuery query = session.CreateSQLQuery(
      "SELECT A.OrderedFrom, C.LastOrdered, A.ContentReferenceId, B.Title 
        FROM TranslationContentReference A
         INNER JOIN TranslationOrder C ON (A.TranslationOrderId = C.Id)
         INNER JOIN ContentLibrarySearch B ON (A.ContentReferenceId = b.ContentReferenceId)
        WHERE A.ToLanguageId = :language");
    query.SetString("language", "xxxx-xxxx-xxxx-xxxx-xxxx");
    var result = query.SetResultTransformer(new AliasToBeanResultTransformer(typeof(MyDTO)))
    .List();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I have two tables, admin_privilege and admin_roll_privilege. I'm trying to write a query
Not sure why I can't figure this one out. Basically, I have two tables
I have two tables, a_users and a_student_tutors. I am basically looking to join the
I am trying to join two tables: table A and table B. Table A
I have two tables that look like this: node: NID Name 1 Chicago 2
Basically, I have two tables, one with Some posts on and another for comments,
I'm trying to perform a complex issue, I have a query structured like this:
I'm trying to get a query to compare two tables by LEFT OUTER JOINing
I'm basically trying to create a url friendly query string with user input. The
I'm having an issue with MySQL. I have two tables, categories and topics. I

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.