我有以下核心数据模型,其中ProFormaPeriod抽象实体 FiscalPeriod的子类。在我的提取请求中,我想从CalendarPeriod遍历到IBEstType

我该怎么做,因为fiscalPeriod是我在代码完成中获得的唯一关系,而不是ProformaPeriod

我是否需要建模从CalendarPeriodProformaPeriod的其他直接关系?

最佳答案

一种方法是获取FiscalPeriod并遍历结果以检查正确的类并过滤出正确的IBEstType。相对于谓词中的直接键路径,它仍然应非常有效,具体取决于数据的大小。

否则,是的,您将必须使子实体成为直接关系。

要检查 class :

for (NSManagedObject *obj in fetchedFiscalPeriods) {
    if ([obj isKindOfClass:[ProformaPeriod class]]) {
        ProformaPeriod *period = (ProformaPeriod*) obj;
        // check period.estimateType
    }
}

08-18 09:24