Lá vem eu novamente, hehe
Estive dando umas pesquisadas e achei essas duas questões no
StackOverflow:
Do we need to use the Repository pattern when working in
ASP.NET MVC
with ORM solutions?
http://stackoverflow.com/questions/4724345/do-we-need-to-use-the-repository-pattern-when-working-in-asp-net-mvc-with-orm-sol
Generic Repository With EF 4.1 what is the point
http://stackoverflow.com/questions/5625746/generic-repository-with-ef-4-1-what-is-the-point
Isto levantou a questão de que um ORM como o Entity Framework já tem o
repository pattern:
"DbContext is implementation of unit of work pattern and IDbSet is
implementation of repository pattern."
E o uso de uma outra abstração do ORM é alegado pra se algum dia você
quiser trocar o ORM, mas quanto isso acontece na realidade? Existe
outros benefícios: In the same time wrapping EF code can keep your
code better organized and following Separation of concern rule. For me
this can be the only real advantage of repository and unit of work but
you have to understand that following this rule with EF will maybe
make your code better maintainable and better readable but in the
initial effort to create your application will be much higher and for
smaller applications this can be unnecessary complexity.
E está nova abstração do ORM deixa seu trabalho com EF muito mais
difícil, porque por padrão o ORM já tem várias features que se você
abstrair ele você não vai usar essas features e se precisar usar, vai
ter que implementar.
Isso é mais um assunto pra discussão do que uma questão, onde por moda
de tanto que se fala em Repository Pattern o pessoal querer
implementar isso em todo lugar, deixando de evitar o YAGNI.
Vocês concordam?