I have core data model with entities department and employees with to-many relationship from department to employee (department-->> employee).I need to fetch all the departments with employees joining date between two dates.
How to Set the predicate for this ???
Thank You....
I think you need a SUBQUERY here:
[NSPredicate predicateWithFormat:@"SUBQUERY(employees, $e, $e.joinDate >= %@ AND $e.jointDate >= %@).@count > 0",
fromDate, toDate]
employees is the to-many relationship from Department to Employee.
(See expressionForSubquery:usingIteratorVariable:predicate: in the "NSExpression Class Reference", where a similar problem and the SUBQUERY solution is documented).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With