开发者

How do I map class like Types<Type> in NHibernate?

开发者 https://www.devze.com 2022-12-09 01:42 出处:网络
I have a need for specialize collection of custom typ开发者_Python百科es in my Domain Model. public class Foos : List<Foo>

I have a need for specialize collection of custom typ开发者_Python百科es 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 ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号