我想模擬以下關係。Castle ActiveRecord OneToOne和JoinedBase/Key一起創建沒有SQL關係
[JoinedBase]
MasterForm{
Guid MasterFormId {get;set;}
/* some base properties like modifiedBy etc... */
}
[ActiveRecord]
TerminationForm{
[PrmaryKey(Foreign)]
Guid MasterFormId {get; set;}
/* Some more properties specific to terminations */
}
[ActiveRecord("TermStaffing")]
public class TermStaffing : StaffingBase, ITermStaffing
{
}
public abstract class StaffingBase : EntityBase<StaffingBase>, IStaffingBase
{
protected StaffingBase()
{
}
protected StaffingBase(string createdBy)
{
this.CreatedBy = createdBy;
}
[PrimaryKey(PrimaryKeyType.Foreign)]
public virtual Guid MasterFormId
{
get; set;
}
}
這一切形式的主類繼承......基本形式,然後一些具體形式 ..TerminationForm,另一種形式......等等......
然後我會掛一些其他形式的部分關閉每個孩子的形式。我將這些子表單建模爲[OneToOne]
即,如果TerminationForm類似於上面的FormOne ..我在它下面有「Staffing」..這是鏈接..和它的相互鏈接(注意...我也將一些Staffing屬性拉入抽象基礎,因爲我有TerminationStaffing和LeaveStaffing)
[OneToOne(MapType = typeof(TermStaffing), Cascade = CascadeEnum.All, PropertyRef = "MasterFormId", ForeignKey = "FK_TerminationFormsStaffing", Constrained = true)]
public virtual ITermStaffing Staffing
[OneToOne(MapType = typeof(TerminationForm), PropertyRef = "MasterFormId", ForeignKey = "FK_StaffingTerminationForms", Constrained = true)]
public virtual ITerminationForm TerminationForm
當AR創建架構..它正確地涉及TerminationForm通過這限制了它們的主鍵關係型模...
然而,即使TerminationStaffing表包括MasterFormId我不」看看創建的關係。我應該擔心這個嗎?也許我可以將它添加後,但我很驚訝。
我想過使用[屬於關聯]上TerminationStaffing但是隨後在TerminationForm(的關係是一對一的..不一對多)
我是大錯特錯什麼關係呢?