Reputation: 1703
I have two entities: class and student. each class can have many students, that is 1 to N reletionship. class entity has two proerties : class name and toStudent; student entity has two properties: student name and toClass;
How do I set the predicate so that I can get an array of classes which do not contain a specific student name. If the class does not have any student, it should also be in the array.
Upvotes: 0
Views: 26
Reputation: 4705
Try the below predicate
predicate = [NSPredicate predicateWithFormat:@"(SUBQUERY(toStudent, $student, $student.studentname == %@).@count == 0)",@"student_name_here"];
Upvotes: 1