C#中的业务对象树 [英] Tree of business objects in C#

查看:68
本文介绍了C#中的业务对象树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我需要找到有关我项目中一个细节的有效解决方案.

我有一棵类别和人工制品(或产品)的树.类别可以包含其他类别或产品.如何组织这些对象的业务逻辑?

我的解决方案在这里:

<pre>public class CategoryBO
    {
        public int CategoryID { get; set; }
        public string Name { get; set; }
        public List<CategoryBO> Categories { get; set; }
        public List<ArtefactBO> Artefacts { get; set; }
    }





我的一个朋友建议我将其财产用作父母:

<pre>public class CategoryBO
    {
        public int CategoryID { get; set; }
        public string Name { get; set; }
        public CategoryBO Parent { get; set; }
        public List<CategoryBO> Categories { get; set; }
        public List<ArtefactBO> Artefacts { get; set; }
    }





解决方案

第二种方法更灵活,因为它从类别中提供了父类别.在第一种方法中,要查找父类,您必须进行一些迭代.如果需要在过程的任何阶段找到父类,则第二种要好得多.


Hi there!

I need to find out effective solution about one detail in my project.

I have a tree of categories and artefacts(or products). Category can consists of other categories or products. How to organize business logic for these objects?

My solution is here:

<pre>public class CategoryBO
    {
        public int CategoryID { get; set; }
        public string Name { get; set; }
        public List<CategoryBO> Categories { get; set; }
        public List<ArtefactBO> Artefacts { get; set; }
    }





One my friend sugests me to use the property for parent:

<pre>public class CategoryBO
    {
        public int CategoryID { get; set; }
        public string Name { get; set; }
        public CategoryBO Parent { get; set; }
        public List<CategoryBO> Categories { get; set; }
        public List<ArtefactBO> Artefacts { get; set; }
    }





Which way is more effective or may be you know more flexible trick for this issue?

解决方案

The second one is more flexible since it gives the Parent Category from a category.In the first method , for finding the parent you have to do some iterations.If you have a requirement to find the parent category at any stage of your process the second one is much much better.


这篇关于C#中的业务对象树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆