在业务层和数据访问层之间维护对象的好方法是什么? [英] What is the good way of maintaining the objects between Business Layer and DataAccess Layer?

查看:145
本文介绍了在业务层和数据访问层之间维护对象的好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个项目,一个是我的Web应用程序,第二个是业务逻辑,第三个是os Dataaccess层项目.我在业务逻辑项目中有一个称为Base.cs的类,即使在数据访问层项目中我也需要该类,但是问题是,如果我尝试向数据访问层添加业务逻辑项目的引用,那就是说循环引用可以不用补充,我知道为什么这么说.我想知道维护此类的最佳方法是什么?我可以为共享类再创建一个项目,这样我就可以将该引用添加到业务逻辑项目和数据访问层项目中吗?

Hi , I have a 3 projects in my slution one is my web application, 2nd one is Business logic and third one os Dataaccess layer project. I have a class called Base.cs in Business logic project, i need this class even in dataaccess layer proj also but the prob is if i try to add a reference of business logic projec to the dataaccess layer, it is saying the circular references can''t be added, i know why it is saying that. I would like to know what is best way of maintaing such classes? Can i create one more proj for the shared classes, this way i can add that reference to both business logic project and data access layer proj?

推荐答案

是的.您可以为此将数据访问项目,业务逻辑项目或Web项目分解为多个项目.这就是您要重用多少,何时何地重用.我认为您会对以下文章感兴趣(由Robert Martin或Bob叔叔撰写):包装上的ABC [ ^ ].
这些内容是从他的网站上获得的,其中包含更多有关OOD的文章(包括包装上的文章): SOLID [ ^ ].

如何拆分和设计包装取决于您自己.
希望对您有所帮助!
Yes you can. You could break up your data access project, business logic project or web project into multiple projects for that matter. It''s all about how much you want to re-use, where and when. I think you''ll be interested in the following articles (by Robert Martin a.k.a. Uncle Bob): An ABC on packages[^].
They''re taken from his website with more articles, like these ones on OOD (including the ones on packages): SOLID[^].

How you should split up and design your packages is up to you.
Hope it helps!


这篇关于在业务层和数据访问层之间维护对象的好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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