如何在谓词中引用父实体的获取请求中的子实体名称?

Gre*_*tin 7 iphone core-data iphone-sdk-3.0

我需要为抽象基础对象创建复杂谓词.我想为不同的继承实体设置单独的谓词查询并关闭子实体类型,下面的示例是我想要做的,但是,我还没有找到引用实体名称或输入的方法谓词.

NSFetchRequest *request = [[NSFetchRequest alloc] init];
request.entity = [NSEntityDescription entityForName:@"MyCommonObjectBase" inManagedObjectContext:myContext];

NSPredicate *subclassAPredicate = [NSPredicate predicateWithFormat:@"someValue > %@ && entityName = %@", 100, @"SubclassA"];
NSPredicate *subclassBPredicate = [NSPredicate predicateWithFormat:@"someValue < %@ && entityName = %@", 50, @"SubclassB"];

request.predicate = [NSCompoundPredicate orPredicateWithSubpredicates:[NSArray arrayWithObjects:subclassAPredicate, subclassBPredicate, nil]];
Run Code Online (Sandbox Code Playgroud)

Gre*_*tin 12

我在http://bugreport.apple.com问题编号7318897 得到了Apple的回复:

entity.name不是建模属性,因此不合法.它偶然在二元商店工作.获取子实体的正确方法是在NSFetchRequest上执行此操作,并使用setIncludesSubentities.

因此,似乎正确的解决方案是具有单独的提取请求并在执行后合并结果集.