From 1febae72c25ef6e831d8fd238f092c943e82d872 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 22 Oct 2025 17:26:31 +0200 Subject: [PATCH] refactor(DbRepositoryFactory): remvoed --- .../Repository/IRepositoryFactory.cs | 18 ------------ .../DbRepository.cs | 10 ++++--- .../DependencyInjection.cs | 3 -- .../Factory/DbRepositoryFactory.cs | 28 ------------------- 4 files changed, 6 insertions(+), 53 deletions(-) delete mode 100644 DigitalData.Core.Abstraction.Application/Repository/IRepositoryFactory.cs delete mode 100644 DigitalData.Core.Infrastructure/Factory/DbRepositoryFactory.cs diff --git a/DigitalData.Core.Abstraction.Application/Repository/IRepositoryFactory.cs b/DigitalData.Core.Abstraction.Application/Repository/IRepositoryFactory.cs deleted file mode 100644 index d77db0f..0000000 --- a/DigitalData.Core.Abstraction.Application/Repository/IRepositoryFactory.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace DigitalData.Core.Abstraction.Application.Repository -#if NET - ; -#elif NETFRAMEWORK - { -#endif - -public interface IRepositoryFactory -{ -#if NET - public -#endif - IRepository Get(); -} - -#if NETFRAMEWORK - } -#endif \ No newline at end of file diff --git a/DigitalData.Core.Infrastructure/DbRepository.cs b/DigitalData.Core.Infrastructure/DbRepository.cs index d33084c..695d6f4 100644 --- a/DigitalData.Core.Infrastructure/DbRepository.cs +++ b/DigitalData.Core.Infrastructure/DbRepository.cs @@ -4,6 +4,8 @@ using DigitalData.Core.Abstractions.Interfaces; using DigitalData.Core.Infrastructure.Factory; using Microsoft.EntityFrameworkCore; using System.Linq.Expressions; +using Microsoft.Extensions.DependencyInjection; + #if NETFRAMEWORK using System.Collections.Generic; using System; @@ -130,14 +132,14 @@ public class DbRepository : IRepository where TDbC public class DbRepository : IRepository { - private readonly IRepositoryFactory _factory; + private readonly IServiceProvider _provider; - public DbRepository(IRepositoryFactory factory) + public DbRepository(IServiceProvider provider) { - _factory = factory; + _provider = provider; } - public IRepository Entity() where TEntity : IEntity => _factory.Get(); + public IRepository Entity() where TEntity : IEntity => _provider.GetRequiredService>(); } #if NETFRAMEWORK diff --git a/DigitalData.Core.Infrastructure/DependencyInjection.cs b/DigitalData.Core.Infrastructure/DependencyInjection.cs index 8440e58..b79618a 100644 --- a/DigitalData.Core.Infrastructure/DependencyInjection.cs +++ b/DigitalData.Core.Infrastructure/DependencyInjection.cs @@ -29,9 +29,6 @@ public static class DependencyInjection // register db repository services.AddSingleton(); - // register db repository factory - services.AddSingleton(); - return services; } diff --git a/DigitalData.Core.Infrastructure/Factory/DbRepositoryFactory.cs b/DigitalData.Core.Infrastructure/Factory/DbRepositoryFactory.cs deleted file mode 100644 index 9cd19e7..0000000 --- a/DigitalData.Core.Infrastructure/Factory/DbRepositoryFactory.cs +++ /dev/null @@ -1,28 +0,0 @@ -using DigitalData.Core.Abstraction.Application.Repository; -using Microsoft.Extensions.DependencyInjection; -#if NETFRAMEWORK -using System; -#endif - -namespace DigitalData.Core.Infrastructure.Factory -#if NET - ; -#elif NETFRAMEWORK - { -#endif - -public class DbRepositoryFactory : IRepositoryFactory -{ - private readonly IServiceProvider _provider; - - public DbRepositoryFactory(IServiceProvider provider) - { - _provider = provider; - } - - public IRepository Get() => _provider.GetRequiredService>(); -} - -#if NETFRAMEWORK - } -#endif \ No newline at end of file