最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

C#中的业务对象树

SEO心得admin137浏览0评论
本文介绍了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.

发布评论

评论列表(0)

  1. 暂无评论