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

  • Home
  • SEARCH
  • 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 896783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:47:03+00:00 2026-05-15T14:47:03+00:00

I am trying to map the collection for two days without success. I also

  • 0

I am trying to map the collection for two days without success. I also read all possible articles and forums but still down there. Ok, here is the problem:

1) The collection class contains a private field “_internalCollection” which is mapped with NHib.

2) The holding entity should expose the collection trough readonly property.

3) I want to avoid implementing NHibernate interface IUserCollectionType!!!

I did this with xml mapping and it work great. The WarehouseEntity is a collection Item. Warehouses is a readonly property in OrgEntity class.

  <component name="Warehouses" class="Core.Domain.Collections.EntitySet`1[Core.Domain.OrgStructure.IWarehouseEntity,Core],Core">
    <set name="_internalCollection" table="`WAREHOUSE`" cascade="save-update" access="field" generic="true" lazy="true" >
      <key column="`WarehouseOrgId`" foreign-key="FK_OrgWarehouse" />
      <!--This is used to set the type of the collection items-->
      <one-to-many class="Domain.Model.OrgStructure.WarehouseEntity,Domain"/>
    </set>
  </component>

Any idea how can I do it with fluent NHibernate?

EDIT: Core.Domain.Collections.EntitySet`1 is base collection class. It provides basic functionality for working with collections and can fit any class which is IEntity interface.

  • 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-15T14:47:04+00:00Added an answer on May 15, 2026 at 2:47 pm

    Try:

    HasMany(x => x.Warehouses)
        .AsSet().KeyColumn("WarehouseOrgId")
        .Access.CamelCaseField(Prefix.Underscore)
        .ForeignKeyConstraintName("FK_OrgWarehouse");
    

    Edit: I missed a key part of the question so here’s another try:

    Component(x => x.Warehouses, m =>
        {
            m.HasMany<Warehouse>(Reveal.Member<EntitySet<IWarehouseEntity>>("_internalCollection")
               .AsSet().KeyColumn("WarehouseOrgId")
               .ForeignKeyConstraintName("FK_OrgWarehouse");
        });
    

    I’m sure that’s not it but hopefully it puts you on the right path. Also have a look using ComponentMap.

    My advice is to avoid custom collections entirely. I replaced all of ours with extension methods on IEnumerable<T>.

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

Sidebar

Related Questions

I'm trying to write a method which takes a Map[K, Collection[V]] and converts it
I'm trying to map a List with an index column. This works fine, but
I'm trying to map a ManyToMany relationships between 2 tables, both having composite primary
I'm trying to map a struct definition using ctypes: struct attrl { struct attrl
I'm new to MVC (and ASP.Net routing). I'm trying to map *.aspx to a
I am trying to use Lambda Expressions in a project to map to a
I am trying to integrate the function into a map where you can enter
I'm trying to make some types in Django that map to standard Django types.
I am trying to compile the following code: private String dataToString(){ Map data =
I'm trying to find the latitude and longitude of the corners of my map

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.