A
A
Aram Aramyan2016-05-18 09:55:39
C++ / C#
Aram Aramyan, 2016-05-18 09:55:39

How to correctly transfer data from the repository (EF)?

We have a UserRepository repository that reads data from the database using the EntityFramework and the UserService service class that accesses the repository. And our UI is already accessing this service.
Let's say a domain model
class User { string Name {get; set; }}
How to give data? Really in the form of domain models?
Options come to mind:
1. Make another UserModel class (UserDto?), in which I will only have the necessary fields, and in the repository method (or in the service) transform the domain model (by simply copying the field values). Alternatively, in order not to copy data, UserModel can be a descendant of User (what difficulties will it cause?)
2. Give the domain model, but first disconnect it from the context.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-05-18
@user004

For a thin client, thin data. copy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question