This commit is contained in:
David Lebee 2019-02-13 22:01:38 -06:00
parent 5465ac3972
commit 4e7cffc966
7 changed files with 31 additions and 10 deletions

View File

@ -9,6 +9,8 @@ namespace PoweredSoft.Data.Core
{
public interface IAsyncQueryableService
{
IEnumerable<IAsyncQueryableHandlerService> Handlers { get; }
IAsyncQueryableHandlerService GetAsyncQueryableHandler<T>(IQueryable<T> queryable);
Task<T> FirstOrDefaultAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken));

View File

@ -9,7 +9,7 @@
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
<RepositoryType>github</RepositoryType>
<PackageTags>powered,soft,orm,db,context,ef,ef6,efcore,factory</PackageTags>
<Version>1.1.1</Version>
<Version>1.1.3</Version>
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;amp;r=g&amp;amp;d=retro</PackageIconUrl>
<Product>PoweredSoft.Data.Core</Product>
<Description>Library to abstract orm.</Description>

View File

@ -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<IAsyncQueryableHandlerService>();
var someService = sp.GetService<IAsyncQueryableService>();
Assert.Equal(2, result.Count());
Assert.Equal(2, someService.Handlers.Count());
}
}
}

View File

@ -9,7 +9,7 @@
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
<RepositoryType>github</RepositoryType>
<PackageTags>powered,soft,orm,db,context,ef,ef6,efcore,factory</PackageTags>
<Version>1.1.2</Version>
<Version>1.1.3</Version>
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;amp;r=g&amp;amp;d=retro</PackageIconUrl>
<Product>PoweredSoft.Data.EntityFrameworkCore</Product>
<Description>the abstraction implementation for EF Core.</Description>

View File

@ -9,7 +9,7 @@
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
<RepositoryType>github</RepositoryType>
<PackageTags>powered,soft,async,queryable,handler</PackageTags>
<Version>1.1.2</Version>
<Version>1.1.3</Version>
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;amp;r=g&amp;amp;d=retro</PackageIconUrl>
<Product>PoweredSoft.Data.MongoDB</Product>
<Description>the abstraction implementation for MongoDB.</Description>

View File

@ -10,12 +10,12 @@ namespace PoweredSoft.Data
{
public class AsyncQueryableService : IAsyncQueryableService
{
public AsyncQueryableService(IEnumerable<IAsyncQueryableHandlerService> asyncQueryableFactories)
{
AsyncQueryableFactories = asyncQueryableFactories;
}
public IEnumerable<IAsyncQueryableHandlerService> Handlers { get; }
public IEnumerable<IAsyncQueryableHandlerService> AsyncQueryableFactories { get; }
public AsyncQueryableService(IEnumerable<IAsyncQueryableHandlerService> handlers)
{
Handlers = handlers;
}
public Task<int> CountAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken))
=> GetAsyncQueryableHandlerOrThrow(queryable).CountAsync(queryable, cancellationToken);
@ -37,7 +37,7 @@ namespace PoweredSoft.Data
public IAsyncQueryableHandlerService GetAsyncQueryableHandler<T>(IQueryable<T> queryable)
{
var handler = AsyncQueryableFactories.FirstOrDefault(t => t.CanHandle(queryable));
var handler = Handlers.FirstOrDefault(t => t.CanHandle(queryable));
return handler;
}

View File

@ -9,7 +9,7 @@
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
<RepositoryType>github</RepositoryType>
<PackageTags>async,queryable,handler,service,di</PackageTags>
<Version>1.1.1</Version>
<Version>1.1.3</Version>
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;amp;r=g&amp;amp;d=retro</PackageIconUrl>
<Product>PoweredSoft.Data</Product>
<Description>Library to abstract orm.</Description>