一个形容词应具有一个类别(一对一), 目标包含操作,并且每个操作都应具有一个操作类别(一对一)和许多资源类别(一对多)。 我不知道如何配置映射。另外我不确定我的设计是否正确,如何正确处理这种情况?
摘要:
我需要3个关系。
1)在Objective和Objective的ObjectiveCategoryId属性上类别之间一对一。
2)ObjectiveAction和ObjectiveAction的ActionCategoryId属性上的类别一对一。
3)类别的ObjectiveId属性上的ObjectiveAction和类别之间一对多。
public class Category {
public int Id { get; set; }
public string Name { get; set; }
}
public class Objective {
private ICollection<DevelopmentObjectiveAction> _actions;
public int Id { get; set; }
public string Name { get; set; }
public int ObjectiveCategoryId { get; set; }
public Category ObjectiveCategory { get; set; }
public ICollection<ObjectiveAction> Actions {
get => _actions ?? (_actions = new List<ObjectiveAction> ());
set => _actions = value;
}
}
public class ObjectiveAction {
private ICollection<Category> _resourceCategories;
public int Id { get; set; }
public string Name { get; set; }
public long ObjectiveId { get; set; }
public long Objective { get; set; }
public int ActionCategoryId { get; set; }
public Category ActionCategory { get; set; }
public ICollection<Category> ResourceCategories {
get => _resourceCategories ?? (_resourceCategories = new List<Category> ());
set => _resourceCategories = value;
}
}