[HasMany(typeof(EmployeeInfo),Table="EmployeeInfo",ColumnKey="DepartID",Cascade=ManyRelationCascadeEnum.AllDeleteOrphan)]public IList EmployeeInfo { get; set; }
employee中这么写的:
[BelongsTo("DepartID")]
public Department Department { get; set; }
后台删除的时候这样写的:
protected void deletebtn_Click(object sender, EventArgs e)
{
Department depart = Department.FindByID(6);
using (TransactionScope tan = new TransactionScope())
{
try
{
depart.Delete();
tan.VoteCommit();
}
catch
{
tan.VoteRollBack();
}
}
Bind();
}
其实这是我参照网上的教程写的,但是我删除的时候提示无法将NULL值插入列“DepartID”