iPhone开发-使用CoreData查询相关记录
我有一个案例,我有三个具有一对多和一对多关系的实体:
Entity A (Entity B relationhip),
Entity B (Entity A relationship, Entity C relationship),
Entity C (Entity B relationhip)
我有实体 A 的引用,现在我想获取所有相关的实体 C 记录。我怎样才能做到这一点? (用最少的代码)
编辑:这是另一种表达方式。
我们可以与 CoreData 执行连接吗?例如,(这是一个非常粗略的例子),我们有一个以下实体关系:
Grand Parent (1)---(m) Parent
Parent (1)---(m) Child
那么,现在如果我有“阿尔伯特”祖父母,并且我想得到他所有的孙子,我该怎么做?
I have a case where i have three entities with one-to-many and one-to-many relationships:
Entity A (Entity B relationhip),
Entity B (Entity A relationship, Entity C relationship),
Entity C (Entity B relationhip)
I have the reference of Entity A, and now i want to fetch all the related Entity C records. How can i do that? (with least amount of code)
Edit: Here's another way to put it.
Can we perform joins with CoreData. For example, (and this is a very crude example), We have a following entity-relationship:
Grand Parent (1)---(m) Parent
Parent (1)---(m) Child
So, now if i have "Albert" the Grand Parent, and i want to get all his grand children, how can i do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果其他人偶然发现类似的情况,这对我有用:
我主要感兴趣的是读取实体 C 中单个字段的数据(链接到 myEntityA 对象)。这里的关键概念是“不要将 CoreData 视为‘数据库’”。
In case someone else stumble across a similar situation, here's what worked for me:
I was mainly interesting in reading the data of a single field in Entity C (that's linked to myEntityA object). The key concept here is that "don't think of CoreData as a 'database'".