English 中文(简体)
• 如何适当校外删除核心数据中的受管制物体?
原标题:How to properly cascade delete managed objects in Core Data?

我有一个核心数据模型,有三个实体:A、B和C.A与B有着一对一的关系,B与C有着许多对手的关系。 A->的删除规则;B为“Cascade”,B为“No Action”。 B->的删除规则;C是“无行动”,C->B是“不行动”。

我在某个实体中很难删除。 我想做的是:

  1. I delete an instance of A (using deleteObject:)
  2. The delete propagates to any B s associated with A (due to the "Cascade" delete rule)
  3. All B s associated with A are deleted
  4. Any relationships belonging to C s whose associated B s were deleted, are also removed

这可能是一个小小的混淆,因此,请允许我指出: 在删除A时,删除所有相关的B条。 凡是提到这些B的C,都不得再提及它们。

在我的测试中,我看不到“学校”完全删除了我的规则工作。 在我删除A时,我随即援引<代码>待处理<>代码/代码>(确保删除)。 然后,我比较了在删除之前和之后列入NSManagedObjectContext的A s和Bs。 A的例子已适当删除(A总数少于删除之前)。 然而,B号数保持不变。 因此,“学校”删除规则似乎没有得到遵守。

我知道,我可以人工地通过A-> B关系,并人工删除B。 然而,这似乎是一种免费提供的核心数据,因此我不想这样做,除非核心数据不足。 欢迎关于使用“学校”删除规则的任何信息。

最佳回答
问题回答

根据

Any relationships belonging to C s whose associated B s were deleted, are also removed Suggests that the B-C should also have Cascade.

此外,如果删除B,那么Cs也应删除。 也是偶然。

  • Nullify is often used as an inverse deletion rule*

页: 1 与A的关系是“补偿”。 与B的关系是Nulllification。 删除C时,B是NOT。 删除B;删除A。

如同在座标。

A--->>B Cascade <---- Nullify

B--->>C Cascade <---- Nullify





相关问题
Is it bad to rely on foreign key cascading?

The lead developer on a project I m involved in says it s bad practice to rely on cascades to delete related rows. I don t see how this is bad, but I would like to know your thoughts on if/why it is.

NHibernate Definitive Cascade application guide

Are there any internet resources that have a definitive guide to all of the cascade settings for NHibernate that will include examples of the class structure, HBM and the implications of actions with ...

NHibernate Cascade none still updating related entity

I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO classes: public class Webpage { public virtual int Id { get; set; } public virtual ...

Nhibernate Cascade

What does Cascade in Nhibernate mean? I see a lot of options in cascading: Delete All AllDeleteOrphan DeleteOrphan SaveUpdate Can you explain these with with examples and their distinctions?

Jquery.cascade plugin change the format of the Ajax URL

I m using the jQuery.Cascade plugin in my Asp.Net MVC application. I ve got it all working in a manner as follows: jQuery("#CompareModelList").cascade("#CompareManufacturerList", { ...