hbm to fluent nhibernate mapping help

Posts   
 
    
PaulLehan
User
Posts: 35
Joined: 19-Nov-2011
# Posted on: 03-Oct-2013 16:40:26   

I'm trying to follow the custom collection workaround defined here:

http://colinjack.blogspot.ie/2008/09/nhibernate-mapping-custom-collections.html

So the basic classes involved are **MyContainingClass **and FooCollection. **MyContainingClass **has a member of type FooCollection.

The problem I have is trying to convert the hbm mapping to a fluent nhibernate equivalent. The article refers to this mappping

<component name="FooCollection" access="nosetter.camelcase-underscore">
 <bag name="_innerList" cascade="all-delete-orphan" access="field" lazy="true">
   <key column="ContaingClassesID" />
   <one-to-many class="..." />
 </bag>
</component>

and I have attempted to alter MyContainingClassMap.cs to add the following

Component(a => a.FooCollection,cp =>
                cp.HasMany<Foo>(Reveal.Property<FooCollection>("Items"))
                .Table("Foo")
                .KeyColumn("MyContainingClassId").AsBag());

However when I attempt to add a Foo item to MyContainingClass.**FooCollection **nothing is persisted. Is my mapping conversion bogus or is something else at play?

Reference

public partial class FooCollection : MyProject.Common.Collections.BaseList<Foo>
{
        private IList<Foo> items;

        partial void OnCreated();

        public IList<Foo> Items
        {
            get { return items; }
            set { items = value; }
        }

        public FooCollection () 
        {
            items = this.baseList;      
        }
}
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Oct-2013 03:12:31   

Hi Paul,

I fail to see how this is related to LLBLGen. Do you want to generate like that custom type of collections? If so I recommend you first have a working case on NHibernate, then you could create your own HBM template version into LLBLGen to generate that from your LLBLGen project.

David Elizondo | LLBLGen Support Team
PaulLehan
User
Posts: 35
Joined: 19-Nov-2011
# Posted on: 04-Oct-2013 10:43:08   

daelmo wrote:

Hi Paul,

I fail to see how this is related to LLBLGen. Do you want to generate like that custom type of collections? If so I recommend you first have a working case on NHibernate, then you could create your own HBM template version into LLBLGen to generate that from your LLBLGen project.

I agree with you, scratches head - no idea why I posted this here.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39898
Joined: 17-Aug-2003
# Posted on: 04-Oct-2013 11:04:17   

Heh simple_smile No worries, happens to the best of us wink

Frans Bouma | Lead developer LLBLGen Pro