I have an entity A with a many to many relationship "events" with entity Event. Entity Event has an attribute eventName.
I want to be able to fetch all entity As that have a given set of Event entitys that match the entityName selected by the user. For an ANY fetch, a compound OR predicate works fine. But for an ALL fetch (where only entity As that have ALL of the user chosen events will be fetched) the compound AND predicate returns a nil!
I was told that I would have to use subqueries. My deliema is that I am having a hard time figuring out how to form a subquery string.
The format is as follows...
SUBQUERY(collection_expression, variable_expression, predicate);
I'll have the eventName string selected by the user so that is dynamic. So what should my subquery look like if I want to use the LIKE[d] operator?
the collection_expression would be the relationship "events" if i am not wrong?
kindly help me out with this.
thankyou.
In reverse order:
Go to the "Content" link, https://forums.developer.apple.com/content
The threads you've created should show up under 'Authored'. The threads you've posted in should show up under 'Participated'.
For
(SUBQUERY(events,$x, $x.event LIKE[d] %@))
it's important to understand that it's an expression which evaluates to a collection, not a single boolean value. That means that
(SUBQUERY(events,$x, $x.event LIKE[d] %@))
by itself isn't a valid predicate because doesn't evaluate to a boolean value. You need to embed the subquery expression in a complete boolean expression like
(SUBQUERY(events,$x, $x.event LIKE[d] %@)).@count > 0