我有一个接口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);
}
}
由于我不止一个,我不知道该怎么做。有什么建议吗?