多接口的NHibernate映射

时间:2011-04-15 20:22:11

标签: nhibernate orm nhibernate-mapping

考虑以下接口和类......

public interface ICategoryParent
{
    ICollection<Category> Categories { get; set; }
}

public interface IColorParent
{
    ICollection<Color> Colors { get; set; }
}

public class Category
{
    public string Name { get; set; }
    public ICategoryParent Parent { get; set; }
}

public class Color
{
    public string Hue { get; set; }
    public IColorParent Parent { get; set; }
}

public class ObjectA : ICategoryParent, IColorParent
{
    //[....] Some other properties
    ICollection<Category> Categories { get; set; }
    ICollection<Color> Colors { get; set; }
}

public class ObjectB : ICategoryParent, IColorParent
{
    //[....] Some other properties
    ICollection<Category> Categories { get; set; }
    ICollection<Color> Colors { get; set; }
}

有人能指出我如何在NHibernate(或Fluent NHibernate)中正确映射这个问题吗?

理想情况下,Categories和Colors表将有一个鉴别器列,让我们知道具体的父类型的类型。我还希望ObjectA和ObjectB急切地加载Categories和Colors属性。

谢谢, 马特

0 个答案:

没有答案