I've heard of the repository pattern and its use/purpose seems very similar to Data Transfer Objects. Are these two things synonymous? If not, can you please provide an explanation?
Gaining competency by discovering my incompetencies.
DTOs are objects that are primarily used to transfer data between application boundaries, such as that between an HTTP or SOAP service and a client application (think Web API and an AJAX call from the browser).
The repository pattern describes a component that is responsible for communicating with the database (usually), but presents business objects to the business layer. Entity Framework DbSets are examples of the repository pattern.
Member
557 Points
1281 Posts
Are DTOs the same as using the Repository pattern?
Aug 27, 2015 04:38 PM|newbie2C#|LINK
I've heard of the repository pattern and its use/purpose seems very similar to Data Transfer Objects. Are these two things synonymous? If not, can you please provide an explanation?
All-Star
194434 Points
28074 Posts
Moderator
Re: Are DTOs the same as using the Repository pattern?
Aug 27, 2015 05:07 PM|Mikesdotnetting|LINK
DTOs are objects that are primarily used to transfer data between application boundaries, such as that between an HTTP or SOAP service and a client application (think Web API and an AJAX call from the browser).
http://www.asp.net/web-api/overview/data/using-web-api-with-entity-framework/part-5
The repository pattern describes a component that is responsible for communicating with the database (usually), but presents business objects to the business layer. Entity Framework DbSets are examples of the repository pattern.
https://msdn.microsoft.com/en-us/library/ff649690.aspx
Business objects are not DTOs, although Business Objects without behaviour might look like them.