我有一个接口,ISportsPerson
它由一些类实现:
public interface ISportsPerson
{
string Name { get; set; }
int Salary { get; set; }
}
public class Footballer : ISportsPerson
{
public virtual string Name { get; set; }
public virtual int Salary { get; set; }
}
public class Cricketer : ISportsPerson
{
public virtual string Name { get; set; }
public virtual int Salary { get; set; }
}
...
我有一堂有一群运动人士的班级
public class Award
{
public virtual IList<ISportsPerson> Winners { get; set; }
}
显然,当我自动映射它时,我得到一个错误:
NHibernate.MappingException: Association references unmapped class: ISportsPerson
如果我只有一个实现,我会将它映射到覆盖中:
public class AwardOverride : IAutoMappingOverride<Award>
{
public void Override(AutoMapping<Award> mapping)
{
mapping.HasMany<Footballer>(x => x.Winners);
}
}
因为我有不止一个,我不知道该怎么办。有什么建议么?