我有一个例外“System.InvalidOperationException:尝试在使用流畅的nhibernate构建配置时添加集合'Media'。我只有在将一些映射提取到泛型方法中时才有它。 这就是我所拥有的:
public class PartyMap : IAutoMappingOverride<Party>
{
public void Override(AutoMapping<Party> mapping)
{
mapping.MapMedia(); // doesn't work
// mapping.MapMedia<Party>(); doesn't work neither
// this works, but I want to extract this!
// mapping.HasManyToMany(x => x.Media).Table("MediaLinks").Cascade.All();
}
}
// this doesn't work
public static void MapMedia<T>(this AutoMapping<T> mapping)
where T : IEntityInMedia
{
mapping.HasManyToMany(x => x.Media).Table("MediaLinks").Cascade.All();
}
// this works, but I want this method to be generic!
public static void MapMedia(this AutoMapping<Party> mapping)
{
mapping.HasManyToMany(x => x.Media).Table("MediaLinks").Cascade.All();
}
我无法查看生成的映射,因为在导出映射之前我收到此错误。