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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:10:55+00:00 2026-05-16T04:10:55+00:00

I hope someone can help with this please. I am trying to query an

  • 0

I hope someone can help with this please.
I am trying to query an OLAP Fact table with NHibernate, but am struggling to get it to work. Its seems a simple requirement but I just cant see what the problem could be.
I have a central Fact table with several Dimension tables, one of the Dimensions has a secondary Dimension.

So ERD is. Fact >—1 Factor_Dim >—1 Target_Dim

My NHibernate query is.

facts = session.CreateCriteria(typeof(Fact), “facts”)
.CreateAlias(“facts.FactorDimension”, “factDim”, JoinType.InnerJoin)
.CreateAlias(“factDim.TargetDimension”, “targetDim”,JoinType.InnerJoin)
.Add(Restrictions.Eq(“targetDim.TargetID”, targetId))
.List();

The error is “The multi-part identifier “targetdim2_.TargetID” could not be bound.”. The generated SQL does not have the Factor_DIM or Target_DIM tables in the From clause.

Are there any alternative techniques to get this query to work? Id like to stick to this style as opposed to CreateSQLQuery() if possible.

Please help. Thanks.

  • 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-16T04:10:55+00:00Added an answer on May 16, 2026 at 4:10 am

    Linq or QueryOver will be your cleanest solutions. If you are determined to stay with ICriteria you probably would want to wrap each of your entities with a class with common crud methods, it also makes your code access common, so code corrections are done in one place, not over hundres of files or classes.

    Theres plenty of projects at http://nhforge.org/wikis/general/open-source-project-ecosystem.aspx which can help you out. I know NhGen ( http://sourceforge.net/projects/nhgen/ ) creates a CRUD class for each entity based on the NHibernate.Burrows GenericDao class with a few CRUD methods. It takes care of all the aliases and joins so queries become as simple as

    IMessageDao messageDao = new MessageDao();
    // Get All
    IList<IMessage> messageList1 dao.FindAll();
    // Find using QueryByExample
    IList<IMessage> messageList2 = dao.FindByExample(messageDetails, orderBy)).ToList();
    // Find using a simple entity query
    IList<IMessage> messageList3 = messageDao.Find( new [] { Restrictions.Le(MessageHelper.Columns.Date, dateLastChecked) } );
    // Find using a join and a query on said joined entities
    IList<IMessage> messageList4 = messageDao.Find
    ( new []
        {
            Restrictions.Le(MessageHelper.Columns.Date, dateLastChecked),
            Restrictions.Eq(MessageHelper.Columns.IsActive, true))
        }, new[]
        {
            Restrictions.Eq(CategoryHelper.KeyColumns.Rsn, categoryRsn),
            Restrictions.Eq(CategoryHelper.Columns.IsActive, true))
        }, new []
        {
            Restrictions.Eq(ChannelHelper.KeyColumns.Rsn, channelRsn),
            Restrictions.Eq(ChannelHelper.Columns.IsActive, true))
        }
    );
    

    Theres plenty of overrides so you can specify your join type or it naturally assumes inner join.

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

Sidebar

Related Questions

I hope someone can help me with the following... I have this code below
This really, really urks me, so I hope that someone can give me a
I hope someone could help me on this. I want to add a month
i'm trying to get optimize an very old query that i can't wrap my
I hope someone can guide me as I'm stuck... I need to write an
The docs at www.fastcgi.com aren't clear on this (to me), so I hope someone
Hope anyone can shed light on this so I can use pens with dash
I hope this question is not considered too basic for this forum, but we'll
I hope this question does not come off as broad as it may seem
I hope everyone will pardon the length, and narrative fashion, of this question. 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.