我有三个映射如下:
public MainChapterMap()
{
// other properties
HasMany(x => x.ClientSpecific).KeyColumn("MainChapterId");
}
public MainChapterClientMap()
{
// other properties
References(x => x.MainChapter).Column("MainChapterId");
HasMany(x => x.Details).KeyColumn("MainChapterClientId");
}
public MainChapterClientDetailMap()
{
// other properties
References(x => x.MainChapterClient).Column("MainChapterClientId");
}
MainChapter
有许多特定于客户的章节。特定于客户的章节(MainChapterClient
)有许多翻译(MainChapterClientDetail
)
删除规则应如下:
MainChapter
时
MainChapterClient
行MainChapterClientDetail
行MainChapterClient
时
MainChapter
行MainChapterClientDetail
行MainChapterClientDetail
时
MainChapter
行MainChapterClientDetail
行但无论我最终得到这个错误:
删除的对象将被重新保存 级联(从中删除已删除的对象) 协会)[Entities.MainChapterClient#39]
我不知道如何设置我的级联。任何帮助都受到欢迎!
答案 0 :(得分:1)
您需要从双方删除引用:
MainChapterClient.Details.Remove(instance);
instance.MainChapterClient = null;