什么时候Core Data中的DENY删除规则实际上拒绝删除对象? [英] When does the DENY delete rule in Core Data actually deny deletion of an object?

查看:152
本文介绍了什么时候Core Data中的DENY删除规则实际上拒绝删除对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

员工与其部门具有相反的关系,反之亦然。 Employee实体有一个名为department的关系,它有一个DENY删除规则。员工将被删除。现在:DENY实际上是否拒绝删除员工,因为部门仍然引用部门?

An Employee has an inverse relationship to it's Department and vice versa. The Employee entity has an Relationship called department, and it has a DENY delete rule. Employee shall be deleted. Now: Does DENY actually deny deletion of employee, because department is still referencing a Department? Or does it mean that a Department can't be deleted because an Employee is referencing it?

推荐答案

删除规则总是被查看从他们被设置的对象的角度,所以我想你有你的描述向后。在这种情况下你想要的是:

Deletion rules are always looked at from the point of view of the object they are being set on so I think you have your description backwards. What you would want in that situation is:


  • 员工可以随时删除,并且与其部门的关系应该被取消。这意味着您将部门关系设置为无效。

  • Employee can be deleted any time and it's relationship to it's department should be nullified. This means you set the department relationship to nullify.

部门只有在不再有员工时才能删除。

Department can only be deleted if it no longer has any employees. This calls for a deny rule which would prevent the deletion of a department if it contains any employee records at all.

这是一个拒绝规则,如果它包含任何员工记录,你的描述暗示了相反的意思,这意味着该员工不能被删除,除非它的部门设置为零。虽然当然可能,但似乎不必要。

Your description implied the reverse which would mean that the employee could not be deleted unless it's department was set to nil. While certainly possible, it seems unnecessary.

这篇关于什么时候Core Data中的DENY删除规则实际上拒绝删除对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆