Developer 02 72603f836c Refactor repository pattern and dependency injection
This commit introduces a new `DbRepository` class implementing the `IRepository<TEntity>` interface, providing asynchronous methods for CRUD operations. The previous CRUD repository registration in `DIExtensions.cs` has been removed, indicating a shift in repository management. A new static class `DependencyInjection` has been added to facilitate the registration of `DbRepository` with the service collection, enhancing modularity and flexibility in database interactions.
2025-04-16 09:12:06 +02:00

44 lines
1.2 KiB
C#

using DigitalData.Core.Abstractions.Infrastructure;
using Microsoft.EntityFrameworkCore;
using System.Linq.Expressions;
namespace DigitalData.Core.Infrastructure;
public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbContext : DbContext where TEntity : class
{
protected TDbContext Context;
protected DbSet<TEntity> Entities;
public DbRepository(TDbContext context, Func<TDbContext, DbSet<TEntity>> queryFactory)
{
Context = context;
Entities = queryFactory(context);
}
public Task<TEntity> CreateAsync<TDto>(TDto dto)
{
throw new NotImplementedException();
}
public Task<TEntity> CreateAsync<TDto>(IEnumerable<TDto> dtos)
{
throw new NotImplementedException();
}
public Task<IEnumerable<TEntity>> DeleteAsync<TDto>(Expression expression)
{
throw new NotImplementedException();
}
public Task<IEnumerable<TEntity>> ReadAsync(Expression? expression = null)
{
throw new NotImplementedException();
}
public Task<IEnumerable<TEntity>> UpdateAsync<TDto>(TDto dto, Expression expression)
{
throw new NotImplementedException();
}
}