在核心数据实体中查找对象,例如 JOIN 或 WHERE 语句
我有两个实体,我想在核心数据中进行联接。我知道 Core Data 不是 MYSQL 数据库,但我不知道如何解释它。
这是我的实体:
Entitys.png http://img833.imageshack.us/img833/226/bildschirmfoto20120110u.png
EntitySetsCards 可以有许多笔记(EntityNotes)。
1 ------------------------------------------------- -> n 关系。
EntitySetsCards 包含主行,如果
,则应显示 EntityNotes EntitySetsCards.cardId == EntityNotes.notesCardId
在mysql中,我会这样做(query1):
SELECT * FROM EntitySetsCards
INNER JOIN EntityNotes ON EntitySetsCars.cardId = EntityNotes.notes_cardId
或 this(query2):
SELECT * FROM EntitySetsCards, EntityNotes
WHERE EntitySetsCars.cardId = EntityNotes.notes_cardId
我怎样才能做像上面的代码(query2)这样的查询?
I have two Entities and I want to do a JOIN in Core Data. I know Core Data is not a MYSQL Database but I don't know how I can explain it otherwise.
Here are my Entities:
Entitys.png http://img833.imageshack.us/img833/226/bildschirmfoto20120110u.png
EntitySetsCards can have many notes(EntityNotes).
1 --------------------------------------------------> n Relationship.
EntitySetsCards contains the main rows and EntityNotes should be displayed if
EntitySetsCards.cardId == EntityNotes.notesCardId
In mysql, I would do this(query1):
SELECT * FROM EntitySetsCards
INNER JOIN EntityNotes ON EntitySetsCars.cardId = EntityNotes.notes_cardId
or this(query2):
SELECT * FROM EntitySetsCards, EntityNotes
WHERE EntitySetsCars.cardId = EntityNotes.notes_cardId
How can I do a query like the code above(query2)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CoreData 不是关系数据存储。它是一个对象存储。只需获取
EntitySetsCards
的notes
属性,对象就会自动实例化。CoreData is not a relational datastore. It is an object store. Simply get the
notes
property of anEntitySetsCards
and the objects will be instantiated automagically.