Derivation attribute with filter/predicate/subquery?

Is it possible to create a derived attribute with a subquery?


Given two entities Feed and Item, where a Feed has many items, and an Item has an isRead attribute. I'd like to be able to specify a Derivation attribute on Feed with the following expression:


SUBQUERY(items, $item, $item.isRead != 1).@count


i.e. the number of unread items.


When I use this expression and run this I get an error:


Unable to generate optimized model (sql model generation failed Error Domain=NSCocoaErrorDomain Code=134097 "(null)" UserInfo={NSUnderlyingException=Invalid keypaths found in derived attribute (unsupported function)})