mercredi 29 juillet 2015

What's the correct way to implement a web service with the repository pattern

I'm about to start a project which will require a web site, connected to a web service. The web service will retrieve data from a database, and return it to the website.

My question is about how to properly separate business concerns with data access.

The service can be separated by utilizing the repository pattern. Then in the service calls implementations I can get the required data from the repository in the form of entities, then return it over the wire.

Similarly I can do the same on the website. Use the repository to hide the implementation details of getting the data from the service and serializing it into an entity or entities.

However, my main issue with this approach is that both the service and the website will both have definitions for their entities. Is there a pattern I can use that will allow me to define these entities once, or is this architecture way off from what is common / best practice.

I should mention that the technologies I'm using are asp.net with c# and I'm not using an entity framework.

Aucun commentaire:

Enregistrer un commentaire