Cyril-hcj
 var entitys= Repository.Table.Where(a => ids.Contains(a.UUID)).ToList();
 entitys.ForEach(a =>
 {
   foreach (var deductionitem in a.Deductionitems){}
   DoDelete(a);
}

 


DeductionItems和主表配了级联删除,代码执行时会抛The relationship could not be changed because one or more of the foreign-key properties is non-nullable

解决方法:

遍历子表后,EF无法分辨该记录是否要保留。所以需要手动删除从表,不能再依赖级联删除

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-04-12
  • 2021-11-25
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2021-05-25
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案