使用聚合对象时,是否使用自定义集合进行关联?

发布于 2024-08-08 21:37:49 字数 744 浏览 2 评论 0原文

例如,最好有:

public class Case : EntityIdentifiable
{
    public Jobs Jobs { get; set; }
    public Vehicles Vehicles { get; set; }
    public Locations Locations {get;set;}

    public IDistances Distances { get; set; }
}

或者

public class Case : EntityIdentifiable
{
    public Dictionary<string,Job> { get; set; }
    public Dictionary<string,Vehicle> { get; set; }
    public Dictionary<string,Location> {get;set;}

    public IDistances Distances { get; set; }
}

我知道我也可以在那里有一个 IDictionary,但我认为这在持久化东西时会有点麻烦。或者也许我只是厌倦了一切都是抽象的并且一直在变化,并且想要至少在某个地方有一些固定点。

目前,我的思考不够深入,无法知道集合类中是否会有很多功能,但可能会有一点。

我还需要记住,我计划使用 NHibernate 来存储我的对象。

你会怎么办 ?

For example is it better to have:

public class Case : EntityIdentifiable
{
    public Jobs Jobs { get; set; }
    public Vehicles Vehicles { get; set; }
    public Locations Locations {get;set;}

    public IDistances Distances { get; set; }
}

or

public class Case : EntityIdentifiable
{
    public Dictionary<string,Job> { get; set; }
    public Dictionary<string,Vehicle> { get; set; }
    public Dictionary<string,Location> {get;set;}

    public IDistances Distances { get; set; }
}

I know that I could have an IDictionary there instead as well, but I had thought this would be bit troublesome when persisting stuff. Or maybe I am just too tired of everything being abstract and allchanging all the time and want at least some fixed points somewhere.

At present I am not thinking forward enough to know if there will be much of functionality in the collection classes, but there may be a bit.

I also need to bear in mind that I plan to use NHibernate to store my objects.

What would you do ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖兔^ω^ 2024-08-15 21:37:49

使用更简单的解决方案。如果您后来发现需要更多,请重构它。

Use the simpler solution. If you discover later that you need more, refactor it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文