除了给定以下类和流利的地图的其他问题之外,有没有办法在删除相关人员时自动级联删除 DriversLicense?请注意,我不希望 Person 类对 DriversLicense 类有任何了解,但如果 Person 被删除,我也不希望出现孤立数据。
public class PersonMap : ClassMap<Person>
{
public PersonMap() { Id( x => x.Id ); }
}
public class PersonMap : ClassMap<Person>
{
public PersonMap() { Id( x => x.Id ); }
}
public class DriversLicense
{
public virtual Person Person { get; set; }
public virtual string State { get; set; }
public override bool Equals( object obj ){ ... }
public override int GetHashCode(){ ... }
}
public class DriversLicenseMap : ClassMap<DriversLicense>
{
public DriversLicenseMap()
{
UseCompositeId().WithKeyReference( x => x.Person );
Map( x => x.State );
}
}