C#中的业务对象树

编程入门 行业动态 更新时间:2024-10-07 06:48:50
本文介绍了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#中的业务对象树

本文发布于:2023-11-30 06:41:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649053.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   业务

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!