Entity framework and n-layered application

牧云@^-^@ 提交于 2019-12-25 04:05:25

问题


so, I have this:

  1. Web App
  2. Business Logic
  3. Data Access Logic

I created in the data access logic, the entities, the context, the initializer.

SO usually the higher layers, call the lower layer functionality, right?

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)

any idea?


回答1:


This is how i did it on a previous project

4 Projects under my Solution

1) UI ( my ASP.NET MVC Application)

2) Business Entities ( My POCOS's for Entities like Customer, Order etc..)

3) Business Logic ( My Inermediate Service Layer which stays in between UI and DataAccess layer. I would do my business specific validations here.

4) The Data Access Layer. Talks to my database. Can be EF / pure ADO.NET Stored Proc etc..

  • DataAccessLayer Project has references of Business Entities Project
  • Business Logic Project has refereces of Business Entities Project
  • UI Project has refereces of Business Entities Project and BusinessLogic.

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.




回答2:


I know this probably isn't very constructive but if I was you I would just add the reference. There no point making things harder on your self to find a more complicated way to do something which should be easy. plus if you skip it now and come across a better solution later you can just modify your code.



来源:https://stackoverflow.com/questions/10482502/entity-framework-and-n-layered-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!