diff --git a/PoweredSoft.Data.Core/IAsyncQueryableService.cs b/PoweredSoft.Data.Core/IAsyncQueryableService.cs index 82a3dcc..637a353 100644 --- a/PoweredSoft.Data.Core/IAsyncQueryableService.cs +++ b/PoweredSoft.Data.Core/IAsyncQueryableService.cs @@ -9,6 +9,8 @@ namespace PoweredSoft.Data.Core { public interface IAsyncQueryableService { + IEnumerable Handlers { get; } + IAsyncQueryableHandlerService GetAsyncQueryableHandler(IQueryable queryable); Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default(CancellationToken)); diff --git a/PoweredSoft.Data.Core/PoweredSoft.Data.Core.csproj b/PoweredSoft.Data.Core/PoweredSoft.Data.Core.csproj index 9065dcc..12f008f 100644 --- a/PoweredSoft.Data.Core/PoweredSoft.Data.Core.csproj +++ b/PoweredSoft.Data.Core/PoweredSoft.Data.Core.csproj @@ -9,7 +9,7 @@ https://github.com/PoweredSoft/Data github powered,soft,orm,db,context,ef,ef6,efcore,factory - 1.1.1 + 1.1.3 https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&r=g&d=retro PoweredSoft.Data.Core Library to abstract orm. diff --git a/PoweredSoft.Data.EntityFrameworkCore.Test/CohabitTest.cs b/PoweredSoft.Data.EntityFrameworkCore.Test/CohabitTest.cs index 5f2f40d..04f5540 100644 --- a/PoweredSoft.Data.EntityFrameworkCore.Test/CohabitTest.cs +++ b/PoweredSoft.Data.EntityFrameworkCore.Test/CohabitTest.cs @@ -8,6 +8,8 @@ using PoweredSoft.Test.Mock; using PoweredSoft.Data.Core; using System.Linq; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using PoweredSoft.Data.MongoDB; namespace PoweredSoft.Data.EntityFrameworkCore.Test { @@ -35,5 +37,22 @@ namespace PoweredSoft.Data.EntityFrameworkCore.Test var shouldBeEfCoreHandler = service.GetAsyncQueryableHandler(efCoreOrders); Assert.Equal(efCoreHandler, shouldBeEfCoreHandler); } + + + [Fact] + public void TestDI() + { + var services = new ServiceCollection(); + services.AddPoweredSoftEntityFrameworkCoreDataServices(); + services.AddPoweredSoftMongoDBDataServices(); + + var sp = services.BuildServiceProvider(); + + var result = sp.GetServices(); + var someService = sp.GetService(); + + Assert.Equal(2, result.Count()); + Assert.Equal(2, someService.Handlers.Count()); + } } } diff --git a/PoweredSoft.Data.EntityFrameworkCore/PoweredSoft.Data.EntityFrameworkCore.csproj b/PoweredSoft.Data.EntityFrameworkCore/PoweredSoft.Data.EntityFrameworkCore.csproj index 219716b..5d896e1 100644 --- a/PoweredSoft.Data.EntityFrameworkCore/PoweredSoft.Data.EntityFrameworkCore.csproj +++ b/PoweredSoft.Data.EntityFrameworkCore/PoweredSoft.Data.EntityFrameworkCore.csproj @@ -9,7 +9,7 @@ https://github.com/PoweredSoft/Data github powered,soft,orm,db,context,ef,ef6,efcore,factory - 1.1.2 + 1.1.3 https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&r=g&d=retro PoweredSoft.Data.EntityFrameworkCore the abstraction implementation for EF Core. diff --git a/PoweredSoft.Data.MongoDB/PoweredSoft.Data.MongoDB.csproj b/PoweredSoft.Data.MongoDB/PoweredSoft.Data.MongoDB.csproj index 1ac656e..ef34b59 100644 --- a/PoweredSoft.Data.MongoDB/PoweredSoft.Data.MongoDB.csproj +++ b/PoweredSoft.Data.MongoDB/PoweredSoft.Data.MongoDB.csproj @@ -9,7 +9,7 @@ https://github.com/PoweredSoft/Data github powered,soft,async,queryable,handler - 1.1.2 + 1.1.3 https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&r=g&d=retro PoweredSoft.Data.MongoDB the abstraction implementation for MongoDB. diff --git a/PoweredSoft.Data/AsyncQueryableService.cs b/PoweredSoft.Data/AsyncQueryableService.cs index d109f8a..8dd9fe7 100644 --- a/PoweredSoft.Data/AsyncQueryableService.cs +++ b/PoweredSoft.Data/AsyncQueryableService.cs @@ -10,12 +10,12 @@ namespace PoweredSoft.Data { public class AsyncQueryableService : IAsyncQueryableService { - public AsyncQueryableService(IEnumerable asyncQueryableFactories) - { - AsyncQueryableFactories = asyncQueryableFactories; - } + public IEnumerable Handlers { get; } - public IEnumerable AsyncQueryableFactories { get; } + public AsyncQueryableService(IEnumerable handlers) + { + Handlers = handlers; + } public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default(CancellationToken)) => GetAsyncQueryableHandlerOrThrow(queryable).CountAsync(queryable, cancellationToken); @@ -37,7 +37,7 @@ namespace PoweredSoft.Data public IAsyncQueryableHandlerService GetAsyncQueryableHandler(IQueryable queryable) { - var handler = AsyncQueryableFactories.FirstOrDefault(t => t.CanHandle(queryable)); + var handler = Handlers.FirstOrDefault(t => t.CanHandle(queryable)); return handler; } diff --git a/PoweredSoft.Data/PoweredSoft.Data.csproj b/PoweredSoft.Data/PoweredSoft.Data.csproj index 016ca1d..f889ad6 100644 --- a/PoweredSoft.Data/PoweredSoft.Data.csproj +++ b/PoweredSoft.Data/PoweredSoft.Data.csproj @@ -9,7 +9,7 @@ https://github.com/PoweredSoft/Data github async,queryable,handler,service,di - 1.1.1 + 1.1.3 https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&r=g&d=retro PoweredSoft.Data Library to abstract orm.