我有一张像这样的大桌子:
TableA:
-ID (PK)
-CA1
-CA2
-CA3
-CA4
...
-CA9
TableB
-ID(PK,FK TableA)
-CB1
我的课程:
只是一些TableA列
public abstract class Base
{
public virtual string CA1 { get; set; }
public virtual string CA2 { get; set; }
public virtual string CA3 { get; set; }
}
更多TableA列
public abstract class Base2 : Base
{
public virtual string CA4 { get; set; }
}
所有Base2属性,以及TableB(具体类)
public class ClassB : Base2
{
public virtual string CB1 { get; set; }
}
我尝试了什么(通过代码映射):
public class BaseOverride : IOverride
{
public void Override(ModelMapper mapper)
{
mapper.Class<Base>(m =>
{
m.Table("TableA");
m.Id(x => x.Id, map =>
{
map.Column("Id");map.Generator(Generators.Identity);
});
m.Discriminator(x =>
{
x.Column("Base2");
});
...
}}
public class Base2Override : IOverride
{
public void Override(ModelMapper mapper)
{
mapper.Subclass<Base2>(j =>
{
j.DiscriminatorValue("Base2");
j.Property(x => x.CB1);
});
}
}
public class ClassBOverride : IOverride
{
public void Override(ModelMapper mapper)
{
mapper.JoinedSubclass<ClassB>(map =>
{
map.Table("TableB");
map.Key(key => key.Column("ID"));
...
});
}
}
我收到了一个错误:
Ambiguous mapping of ClassB. It was registered with more than one class-hierarchy strategy
我知道我在这里使用两种层次结构策略......是否可以解决这个问题?
由于