views:

30

answers:

1

I have a need for specialize collection of custom types in my Domain Model.

public class Foos : List<Foo>
{

}

Is there a way to map this object in NHibernate and how could I use FluentNHibernate to do this as well ?

+1  A: 

NHibernates requires all collections to be mapped as ISomething to facilitate lazy loading. Therefore,

private IList<Foo> foos;

// This is a property that has to be mapped
protected IList<Foo> _Foos
{ 
    get { return foos; } 
    set { foos = value; } 
}

public Foos Foos
{
    get { return new Foos(_Foos); }
}

Don't know though how to map this with Fluent NHibernate.

Anton Gogolev