具有数据层和实体层的实体框架 [英] Entity framework with Data layer and Entity layer
问题描述
这是一个普遍的问题.
我正在使用Visual Studio 2010框架4编写新的Web应用程序.
我想通过层模型使用实体框架 AND :
1.应用层(UI)
2.业务逻辑层(从UI中获取参数,并为数据层准备参数)
3.数据层(执行查询\存储过程)
4.实体层-该层在所有层中均应可见.数据层返回一个实体,应用层将其发送给业务逻辑,业务逻辑可能会对其进行更改...
这些实体应该与数据库中的表基本相同,但是-在某些情况下,我想添加一个附加字段,或者创建一个全新的实体,其中将包括其他一些实体或集合.
是否可以使用实体框架.如果是这样,我应该在哪一层生成实体,以及应该怎么做?
(我找到此页面:
http://msdn.microsoft.com/en-us/magazine/cc700340.aspx [ ^ ]
但它没有实体层)
谢谢
Hi,
This one is a general question.
I am writing a new web application using visual studio 2010, framework 4.
I want to use entity framework AND using layers model:
1. Application layer (UI)
2. Business Logic layer (gets the parameters from the UI, and prepare them for the data layer)
3. Data layer (executes the query \ stored procedure)
4. entities layer - this layer should be visible in all layers. the data layers returns an entity, the application layer sends it to the business logic, business logic might change it...
The entities should be mostly same as tables from DB, but - in some cases I would like to add an additional field, or create a brand new entity which will include some other entities, or collection.
Is it possible using Entity Framework. If so, in which layer should I generate the entities and how should I do that?
(I found this page:
http://msdn.microsoft.com/en-us/magazine/cc700340.aspx[^]
but it doesn''t have an entities layer)
Thanks
推荐答案
您已经回答了您的问题.您的Entity类可以放置在一个单独的库中,其他库可以共享.数据层可以包含ObjectContext方法.
You have already answered your question. Your Entity classes can be placed in a separate library that can be shared between the others. The Data layer can contain the ObjectContext methods.
这篇关于具有数据层和实体层的实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!