mercredi 13 juillet 2016

Sorting, Paging in the Repository pattern & loosely coupled

I have a SalesmanRepository that simply lists all the salesmen from my database. I want to display the result in a grid (imagine a Web interface), so the user can display or hide any field, sort a column and use paging.

Let's assume I have a very large set, so the sorting and paging must be server-side.

My question is, how can I stay loosely-coupled in my architecture?

  1. I don't want my database column's name to the binded to the UI's columns. I want to have the flexibility to change for a new type of database later.
  2. How should I handle paging? By adding parameters such as page and numberOfItemsPerPage directly to the repository's method for example?
  3. How should I approach sorting as well? I don't want either to bind the database column's name to the sorting parameter, as in I could have a new type of database and I would break all my software.

Basically, how can I approach these concept and stay loosely coupled? Ideally, I would like a language-agnostic approach, but I'm using C# if there is a better language-specific answer.

Aucun commentaire:

Enregistrer un commentaire