Reputation: 211
My data model is similar to the above simplified model. At the center is a Person entity and a person can participate in one or more tests. A given test can be taken by one or more persons. Finally a person can be associated with one or more surnames. Most of my queries can be done with just two entities, but I have one that requires all three. I want to return the Tests objects where the Surname.surname = @"someValue". How do I do that?
NOTE: the the relationship testTakenByPerson is drawn incorrectly. It is a to many relationship not a to one relationship as drawn.
Thanks Jim
Upvotes: 0
Views: 169
Reputation: 539955
Similar to this answer https://stackoverflow.com/a/15390492/1187415, you can use SUBQUERY for nested to-many relationships:
[NSPredicate predicateWithFormat:@"SUBQUERY(personsWhoTookTest, $p, ANY $p.surnames.surname == %@).@count > 0", @"someValue"]];
Upvotes: 1