0

我有一个对象CaseNote,它有许多子对象之类的CaseNoteContactType。对于 1 个 CaseNote,可以有 x 个 CaseNoteContactType。在 UI 中,ContactTypes 显示在 CheckListBox 中。

我的问题是如何表示 ContactType 子对象?这是一int|string对简单的。

public Class CaseNote
{
  public Guid CaseNoteID { get; set; }
  ...
  public ??? ContactType { get; set; }
  etc...
// Down here would be Methods for saving, loading, validating, etc...
}

ContactType是一个DictionaryIEnumerable<ContactType>? 一个array, collection, 还是List<ContactType>??

在这些情况下有什么意义?如果没有 CaseNote,ContactType 就不能存在,但足以使其成为对象吗?我不明白每种类型的含义。此外,CaseNote 可以有 0 到 30 个 ContactType 是否重要?

假设我确实走了创建 ContactType 类的路线,子类是否需要一个属性来存储它的父 ID?

指导非常感谢。

如果我离这里很远,那是因为我从来没有真正正确地设置业务对象,现在正在努力使我的环境适应我所阅读的内容。

4

1 回答 1

2

ContactType 听起来像参考数据。一个 CaseNote 可能有 0 个或 N 个 ContactTypes,单个 ContactType 可能与多个 CaseNotes 相关联。那是对的吗?

如果是这样,我建议您创建一个名为 ContactType 的新类型,其中包含两个属性 Id 和 Name(假设这就是 int 和 string 的用途):

public class ContactType
{
    public int Id { get; set; }
    public string Name { get; set; }
}

然后在您的 CaseNote 类中,我会将它们声明为 List(或 IList 接口):

public IList<ContactType> ContactTypes { get; set; }

要检查他们是否有任何 ContactTypes,您可以执行以下操作:

if( myCase.ContactTypes.Count > 0 )
{
    ...
}
于 2010-03-04T23:44:05.573 回答