Repositories
A dedicated class between your application and the database, so every data access call funnels through one place.
Two base classes
BaseRepository<TEntity, TDbConnection> is scoped to a single entity type; DbRepository<TDbConnection> is generic and can serve any entity from one repository instance.
Building one
public class PersonRepository : BaseRepository<Person, SqlConnection>, IPersonRepository
{
public PersonRepository(IOptions<AppSettings> settings)
: base(settings.Value.ConnectionString) { }
public Person Get(int id) => Query(id).FirstOrDefault();
public int Save(Person person) => Insert<int>(person);
}
Registering it with DI
services.AddTransient<IPersonRepository, PersonRepository>();
From there the repository is just another injected dependency — callers depend on the interface, not on RepoDB directly.