我试图做到以下几点,但它抱怨被引用的类'延伸',未发现。我想我需要有针对每个具体类型部件的映射,但我不能指定Attributes.Class两倍。
I'm trying to do the following, but it's complaining that the "classes referenced by 'extends' were not found". I think I need to having a mapping for each concrete type of Component but I can't specify the Attributes.Class twice..
在code是如下:
[NHibernate.Mapping.Attributes.Class(Table = "Components", Abstract = true,
NameType = typeof (Component<ContentItem>))]
public abstract class Component<T> : IComponent<T> where T : ContentItem
{
...
}
[NHibernate.Mapping.Attributes.JoinedSubclass(Table = "ComponentA", ExtendsType = typeof(Component<ItemA>))]
public class ComponentA : Component<ItemA>
{
...
}
[NHibernate.Mapping.Attributes.JoinedSubclass(Table = "ComponentB", ExtendsType = typeof(Component<ItemB>))]
public class ComponentB : Component<ItemB>
{
...
}
在哪里意达和ItemB从ContentItem继承和都被映射。
Where ItemA and ItemB inherit from ContentItem and are all mapped.
您不能映射一个开放的泛型类型这样的,即一个有一个未指定类型参数&LT; T&GT;
。这是行不通的。
You can't map an open generic type like this, i.e. one that has an unspecified type parameter <T>
. It just doesn't work.
Ayende讨论了这个在更详细的他博客。
Ayende discusses this in more detail on his blog.