diff --git a/DigitalData.Core.Infrastructure/DbRepository.cs b/DigitalData.Core.Infrastructure/DbRepository.cs index 879353b..9604962 100644 --- a/DigitalData.Core.Infrastructure/DbRepository.cs +++ b/DigitalData.Core.Infrastructure/DbRepository.cs @@ -1,7 +1,6 @@ using AutoMapper; using DigitalData.Core.Abstraction.Application.Repository; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; using System.Linq.Expressions; namespace DigitalData.Core.Infrastructure; @@ -35,7 +34,7 @@ public class DbRepository : IRepository where TDbC return entities; } - public IQueryable Where() => Entities.AsQueryable(); + public IQueryable Where(Expression> expression) => Entities.AsQueryable().Where(expression); public IQueryable Get() => Entities.AsNoTracking(); @@ -86,5 +85,5 @@ public class DbRepository : IRepository _factory = factory; } - public IRepository Entity() => _factory.Get(); + public IRepository Entity() where TEntity : IEntity => _factory.Get(); } \ No newline at end of file diff --git a/DigitalData.Core.Infrastructure/EntityConfigurationOptions.cs b/DigitalData.Core.Infrastructure/EntityConfigurationOptions.cs deleted file mode 100644 index 16ed3cf..0000000 --- a/DigitalData.Core.Infrastructure/EntityConfigurationOptions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using DigitalData.Core.Abstraction.Application.Repository; -using Microsoft.Extensions.DependencyInjection; - -namespace DigitalData.Core.Infrastructure; - -public class EntityConfigurationOptions -{ - private readonly IServiceCollection _services; - - public EntityConfigurationOptions(IServiceCollection services) - { - _services = services; - } - - public EntityConfigurationOptions AddCustomMapper(Action configure, Func? factory = null) - where TEntityMapper : class, IEntityMapper - { - configure(_services); - - if (factory is null) - _services.AddSingleton, TEntityMapper>(); - else - _services.AddSingleton(factory); - - return this; - } -} diff --git a/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs b/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs index 6debe52..9d98267 100644 --- a/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs +++ b/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs @@ -1,13 +1,13 @@ namespace DigitalData.Core.Tests.Infrastructure; -using DigitalData.Core.Infrastructure; using DigitalData.Core.Tests.Mock; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System.Reflection; using DigitalData.Core.Infrastructure.AutoMapper; -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; +using Bogus.Platform; public class DbRepositoryTests { @@ -22,7 +22,7 @@ public class DbRepositoryTests builder.Services.AddDbContext(opt => opt.UseInMemoryDatabase("MockDB")); - builder.Services.AddDbRepository(context => context.Users).UseAutoMapper(typeof(UserCreateDto), typeof(UserReadDto), typeof(UserBase)); + builder.Services.AddDbRepository(typeof(User).GetAssembly()); builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());