barteloma
barteloma

Reputation: 6865

Do you need Entity Framework entity mapping to Data Transfer Object?

I am reading Domain Driven Desing these days. Applications are C# programming. So I am a bit confused about Data Transfer Objects between layers.

Why I need create DTOs for these layers? Which layer include DTOs, each layers inclue own DTO?

Upvotes: 1

Views: 350

Answers (2)

MikeSW
MikeSW

Reputation: 16348

DTOs as the name implies are objects which just transport data. They don't belong to any particular layer, it's a way to communicate data from one layer or context to another. You're using DTOs so that you don't use that context's objects, which models context specific concepts. This way, one layer isn't coupled to another and their model isn't exposed (because a layer's/context model doesn't have meaning outside that context).

Upvotes: 1

Randy Minder
Randy Minder

Reputation: 48422

This question is going to get closed pretty quickly (too broad and subjective), and probably should be asked in the Programmers exchange. But, I can tell you what we do. All of our DTO objects get created at the data layer. All mapping to and from is at that layer. All code above the data layer uses the DTO objects. This has worked best for us after many different alternatives and failures.

Upvotes: 0

Related Questions