iPhone核心数据得到孙子
如果我为“父-子-孙”设置了实体以及它们之间的一对多关系,我知道我可以获取父级的所有子实体或子级的所有孙子实体。
是否可以运行获取来获取给定父级的所有 Granchild 实体?
感谢您的帮助!
If I have entities set up for Parent - Child - Grandchild and one to many relations between them I know I can then get all the Child entities for a parent or all the Grandchild Entities for a Child.
Is it possible to run a fetch that will get all the Granchild entities for a given Parent?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有每个对多关系的反向关系,您将无法运行您所描述的提取请求。但是,您应该对逆关系进行建模。 CoreData 使用逆来保持对象图的一致性。给定从
Child
到Parent
和Grandchind
到Child
的parent
关系,您可以这样做或带有谓词的
Grandchild
实体上的提取请求:Without inverse relationships for each to-many relationship, no you cannot run a fetch request that you describe. However, you should be modeling the inverse relationships. CoreData uses the inverses to maintain consistency of the object graph. Given
parent
relationships fromChild
toParent
andGrandchind
toChild
, you can door a fetch request on the
Grandchild
entity with predicate: