implement IRepository

This commit is contained in:
tekh 2025-09-10 17:43:42 +02:00
parent 453a0ccdf0
commit 7d3d3b5ae9

View File

@ -1,6 +1,7 @@
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.Linq.Expressions;
namespace DigitalData.Core.Infrastructure;
@ -74,4 +75,16 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
[Obsolete("Use IRepository<TEntity>.Get")]
public IQueryable<TEntity> ReadOnly() => Entities.AsNoTracking();
#endregion
}
public class DbRepository : IRepository
{
private readonly IServiceProvider _provider;
public DbRepository(IServiceProvider provider)
{
_provider = provider;
}
public IRepository<TEntity> Entity<TEntity>() => _provider.GetRequiredService<IRepository<TEntity>>();
}