【问题标题】:ios: CoreData Entity Inheritanceios: CoreData 实体继承
【发布时间】:2015-05-21 07:26:13
【问题描述】:

在我的 ios 应用程序中,我有许多模型类,如 ProjectLead、TeamLead、ProjectManager、Developer,所有这些类都扩展了 Employee 基类。

class Employee{
string name,age,company;
}

class ProjectLead: Employee{
  string pl_1,pl_2,pl_3;
}

class TeamLead:Employee{
string tl_1,tl_2,tl_3;
}
class ProjectManager:Employee{
string pm_1,pm_2,pm_3;
}
class Developer:Employee{
string d_1,d_2,d_3;
}

我可以为我所有的 5 个模型类创建单独的实体。我是否需要为子实体提供父实体属性。如何在 EntityModel 中的实体定义中实现继承

for example Creating ProjectManager Entity

I can add pm_1,pm_2,pm_3 as its attributes, since its extends Employee I have another 3 attributes like name,aga,company. while creating ProjectManage entity Will i have to create it with 3 attributes or 6 attributes?

我只想为我的模型类创建实体,例如 http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started

【问题讨论】:

    标签: ios entity-framework core-data


    【解决方案1】:

    看看这篇文章,它解释了如何在核心数据中使用继承。 https://byunsoo.wordpress.com/2013/03/27/inheritance-in-core-data/

    当您创建实体(例如项目主管)时,您可以在数据模型检查器中选择父实体(例如员工)。

    虽然它确实有一些取舍,但也请仔细考虑一下。
    Core Data entity inheritance --> limitations?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-29
      • 2016-03-31
      • 1970-01-01
      • 2011-05-19
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多