Question

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 ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top