- 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?