关于 coreData 的 fetchrequest 的查询
- 我有一个客户端实体,它与条目实体有很多关系(条目)。
- 客户端实体还与发票实体(发票)具有一对多关系。
发票实体与条目实体(发票)也具有一对多关系。
客户端<--->>>入口
- 客户端<--->>发票
- 发票<--->>输入
当我想为客户端 C1 创建新发票或编辑现有发票 INV1 时,我想获取与客户端 C1 关联且尚未与任何发票关联(尚未开具发票)的所有实体的列表,或者已与 INV1 链接。
简单的 SQL 表示是
SELECT * from entries where client= c1 and (invoice IS null or invoice = INV1)
如何在 CoreData 中编写类似的谓词?
- I have a Client Entity and it has a to many relationship (entries) with Entry entity.
- Client Entity also has a to many relationship with an Invoice Entity (invoices).
Invoice Entity also has a to many relationship with Entry Entity (invoices).
Client <--->> Entry
- Client <--->> Invoice
- Invoice <--->> Entry
When I want to create a new Invoice or Edit an existing Invoice INV1 for a Client C1, I would like to fetch the list of all Entities which are associated with Client C1 and are not associated with any invoice yet (not invoiced yet) or are already linked with INV1.
A plain SQL representation would be
SELECT * from entries where client= c1 and (invoice IS null or invoice = INV1)
How can I write a similar predicate in CoreData?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。
这是一个很好的页面,可以了解更多信息
http:// developer.apple.com/library/mac/#documentation/cocoa/Conceptual/Predicates/predicates.html
我通常在页面右上角下载 pdf。然后我就可以搜索我要找的东西
Try this out.
here is a nice page to learn more
http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/Predicates/predicates.html
i normally download the pdf in the top right of the page. then i can search for what i am looking for