在我的解决方案中,我有一个带关联的业务对象分支.因此,当我尝试在处理后保存根对象时,我得到一个异常,并显示消息"已删除的对象将通过级联重新保存".这意味着删除一个对象后它仍然存在于集合中,其他关联等等.有人知道如何获取已删除对象的引用列表.没有调试器支持很难找到引用.
最常见的场景(我的经验)是有两个根对象具有一些配对/中间对象的集合.
public class Employee
{
public virtual IList<Occupation> Occupations { get; set; }
}
public class Company
{
public virtual IList<Occupation> Occupations { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
现在,我们有Occupation这样的
public class Occupation
{
public virtual Employee Employee { get; set; }
public virtual Company Company { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
那么,会发生什么:
employee.Occupations.CompanyDeleted object would be re-saved by cascade解决方案(S):
Remove()占有也来自company.Occupations(千万不能使用级联)
<bag name="Occupations" lazy="true" inverse="true" batch-size="25"
cascade="all-delete-orphan">
// this above setting on Company side is making issues...
<key column="Company_ID" />
<one-to-many class="Occupation" />
</bag>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5930 次 |
| 最近记录: |