19 lines
686 B
C#
19 lines
686 B
C#
using DigitalData.Core.Abstractions.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace DigitalData.Core.Infrastructure;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static EntityConfigurationOptions<TEntity> AddDbRepository<TDbContext, TEntity>(this IServiceCollection services, Func<TDbContext, DbSet<TEntity>> queryFactory)
|
|
where TDbContext : DbContext
|
|
where TEntity : class
|
|
{
|
|
services
|
|
.AddScoped<IRepository<TEntity>, DbRepository<TDbContext, TEntity>>()
|
|
.AddSingleton(queryFactory);
|
|
|
|
return new EntityConfigurationOptions<TEntity>(services);
|
|
}
|
|
} |