implement IRepository
This commit is contained in:
parent
453a0ccdf0
commit
7d3d3b5ae9
@ -1,6 +1,7 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Abstraction.Application.Repository;
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace DigitalData.Core.Infrastructure;
|
namespace DigitalData.Core.Infrastructure;
|
||||||
@ -75,3 +76,15 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
|
|||||||
public IQueryable<TEntity> ReadOnly() => Entities.AsNoTracking();
|
public IQueryable<TEntity> ReadOnly() => Entities.AsNoTracking();
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DbRepository : IRepository
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _provider;
|
||||||
|
|
||||||
|
public DbRepository(IServiceProvider provider)
|
||||||
|
{
|
||||||
|
_provider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRepository<TEntity> Entity<TEntity>() => _provider.GetRequiredService<IRepository<TEntity>>();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user