Design question on entity framework and Domain Layer -
I am creating a new application using the Entity Framework and the DTOs and Entity Objects would have the same structure but there would be quite a bit of business logic involved. So am wondering which would be the best approach from the following, considering the performance and maintainability of the application
Approach 1:
Expose the Entity Objects to the UI Layer
Approach 2:
I personally wouldn't put BL in my domain models or dtos. My controllers knows about my domain layer and also knows about a business layer. My controllers ask/tell my BL to do work and domain models are returned. Controller layer then maps domain model to dto and sends the dto to view.
In all the projects I have made I combined the two options. When using a grid with columns from 5-6 tables for example its easier to bind the columns to the properties of a Dto because you could avoid binding to subproperties. It's also harder to create gridfilters if a object has to many subproperties.
So in case of data from multiple tables I guess its better to use Dto's
If you have only data from one table I guess its a bit off overkill to create mappings between an Entity and a Dto with exact the same properties.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.