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.