我正在使用流利的nhibernate,并且我正在尝试将我的抽象基类中的一个属性映射到一个特定的表,该表本身不能存在,这取决于派生类是什么。
public class UnmappedClass : Entity<Guid>
{
// This class isn't mapped to a table on its own, its mapping depends on the class that uses it
}
public abstract class BaseClass : Entity<Guid>
{
// mapping depends on derived class, not mapped to anything in base class
protected IList<UnmappedClass> myList = new List<UnmappedClass>();
public virtual IEnumerable<UnmappedClass> Stuff
{
get { return myList.ToList(); }
}
}
public class DerivedClass : BaseClass
{
// At this point, I need to map MyClass in member myList to a table specific to DerivedClass
}
我在覆盖中尝试了以下操作并收到错误Invalid object name 'UnmappedClass'.
mapping.HasMany(Reveal.Member<DerivedClass, IEnumerable<UnmappedClass>>("myList"))
.Table("TableName")
.Access.Field()
.Cascade.AllDeleteOrphan()
.Inverse();