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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:05:19+00:00 2026-05-14T00:05:19+00:00

So I have a set up similar to this questions: Parent Child Setup Everything

  • 0

So I have a set up similar to this questions:
Parent Child Setup

Everything works great when saving the parent and the children.

However, I seem to have a problem when selecting the children. I can’t seem to get all the children with a specific parent.

This fails with: NHibernate.QueryException: could not resolve property: ParentEntity_id of: Test.Data.ChildEntity

Here is my code:

    public IEnumerable<ChildEntity> GetByParent(ParentEntity parent)
    {
        using (ISession session = OrmHelper.OpenSession())
        {

            return session.CreateCriteria<ChildEntity>().Add(Restrictions.Eq("ParentEntity_id ", parent.Id)).List<ChildEntity>();
        }
    }

Any help in building a proper function to get all the items would be appreciated.

Oh, I am using Fluent NHibernate to construct the mappings – version 1 RTM and NHibernate 2.1.2 GA

If you need more information, let me know.

As per you request, my fluent mappings:

            public ParentEntityMap()
    {
        Id(x => x.Id);          
        Map(x => x.Name);           
        Map(x => x.Code).UniqueKey("ukCode");
        HasMany(x => x.ChildEntity).LazyLoad()
            .Inverse().Cascade.SaveUpdate();
    }

    public ChildEntityMap()
    {
        Id(x => x.Id);
        Map(x => x.Amount);
        Map(x => x.LogTime);
        References(x => x.ParentEntity);                
    }

That maps to the following 2 tables:

CREATE TABLE "ParentEntity" (
Id  integer,
Name TEXT, 
Code TEXT,
primary key (Id),
unique (Code)
)

CREATE TABLE "ChildEntity" (
Id  integer,
Amount NUMERIC,
LogTime DATETIME,
ParentEntity_id INTEGER, 
primary key (Id)
)

The data store in SQLite.

  • 1 1 Answer
  • 1 View
  • 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-14T00:05:19+00:00Added an answer on May 14, 2026 at 12:05 am
    return session.CreateCriteria<ChildEntity>()
      .Add(Restrictions.Eq("ParentEntity", parent))
      .List<ChildEntity>();
    

    Just use the parent itself.

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

Sidebar

Related Questions

my issue lokks similar to this one: (link) but i have one-to-many association: <set
I realize questions quite similar to this have been asked, though not exactly this
I have had this issue for years and I've seen similar questions before, but
I have a query that returns a result set similar to the one below:
If I have a function overload set similar to template<typename T> void f(T&& t,
I have 3 tables: parent child parentchild There is a many to many relationship
I read through several questions similar to this one before posting, but did not
I have many similar structure tables like this: CREATE TABLE [dbo].[tbl_Hierarchy]( [ID] [int] NOT
I noticed there are similar questions but I have tried the proposed solutions and
There are similar questions to this such as this but this is different -

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.