jasontaylordev / NorthwindTraders

Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IDbContext and repository pattern

BartoGabriel opened this issue · comments

First, thanks for this repository. It is of great help.

I have some questions regarding the IDbContext and repository pattern.
The Project uses INorthwindDbContext and it feels very comfortable to work directly with the EfCore abstraction. It is very useful for the vast majority of use cases.
But in some cases, I have quite advanced and specific SQL queries. I think those deserve to have an application layer abstraction.

Which leaves me with a few questions:

  1. Would it be correct to use the repository pattern only for certain complex queries? I imagine having the repository Interface in the application layer, and the implementation in Infrastructure.
  2. Since we have some complex queries, in some specific cases we use Dapper, since in some cases it is much more versatile than EF. With which separating those cases in a specific IRepository would allow me in the infrastructure layer to select the framework for the specific use case.

This doubt arises, because in most cases the IDbContext is enough for me.

On the other hand, something I like about the repository pattern is having the aggregate entities identified, and that they only access the parent and not the children. Which brings up the third question:

  1. In the pattern used by this project, can the aggregate entities be identified so that the children are not handled in isolation?

Thanks!

Thank you for your interest in this project. This repository has been archived and is no longer actively maintained or supported. We appreciate your understanding. Feel free to explore the codebase and adapt it to your own needs if it serves as a useful reference. If you have any further questions or concerns, please refer to the README for more information.