问题描述
所以,我有这个:
- Web App
- 业务逻辑
- 数据访问逻辑
我在数据访问逻辑,实体,上下文,初始化器中创建。
I created in the data access logic, the entities, the context, the initializer.
SO通常是较高层,调用较低层的功能,对吗?
SO usually the higher layers, call the lower layer functionality, right?
如果我要保存客户,我想从网络应用程序创建一个客户实体。我不喜欢从Web应用层直接参考数据访问逻辑层(类库)
If I want to save a customer, I want to create a Customer entity from the web app. What I dont like is having a direct reference from the web app layer to the data access logic layer (class library)
任何想法?
推荐答案
这是我在以前的项目中所做的工作
This is how i did it on a previous project
1) UI(我的ASP.NET MVC应用程序)
1) UI ( my ASP.NET MVC Application)
2)业务实体(我的POCOS的实体,如客户,订单等)
2) Business Entities ( My POCOS's for Entities like Customer, Order etc..)
3)业务逻辑(我的Inermediate服务层,它保留在UI和DataAccess层之间,我将在这里进行业务特定的验证。
3) Business Logic ( My Inermediate Service Layer which stays in between UI and DataAccess layer. I would do my business specific validations here.
4)数据访问层跟我的数据库可以是EF /纯ADO.NET Stored Proc等。
4) The Data Access Layer. Talks to my database. Can be EF / pure ADO.NET Stored Proc etc..
- DataAccessLayer项目引用了业务实体项目
- 业务逻辑项目有业务实体项目的引用
- UI项目具有业务实体项目和BusinessLogic的参考。
从UI,我调用中间层(业务逻辑)的方法,并从那里做了自定义验证/业务规则,我将调用数据访问层方法。
From UI, I call methods of Middle Layer (Business Logic) and from there after doing custom validations / business rules, i would call Data Access Layer methods.
这篇关于实体框架和n层应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!