ASP.Net Layered app - Joint entity data structure among layers

How can I share an auto-generated object data model (generated object classes) among all layers of my C # web application, only providing access to the request in the data layer? It uses a typical three-layer approach: data, business, presentation.

My data layer returns IEnumerable<T>to my business layer, but I cannot return type T to the presentation layer, because I do not want the presentation layer to know about the existence of the data layer, where my entity classes are automatically located.

It is recommended that you have a separate layer with the data model only, but I'm not sure how to separate the data model from the query functionality provided by the entity infrastructure.

+3
source share
2 answers

If you use POCO objects (.NET 4+) then this is easy (or at least simpler). Is it possible?

You can create a DTO, as Ben said, but then you basically wrap and duplicate each of the objects. EF2 will create crazy objects and dynamically add change tracking, lazy loading, etc., if you wish.

. Entity Framework, , . DTO. EF 1 EF 2 POCO. http://automapper.codeplex.com/

: , :

+5

DTOs DTO rpesentation.

+2

Source: https://habr.com/ru/post/1745814/


All Articles