1.1.3
This commit is contained in:
parent
5465ac3972
commit
4e7cffc966
@ -9,6 +9,8 @@ namespace PoweredSoft.Data.Core
|
|||||||
{
|
{
|
||||||
public interface IAsyncQueryableService
|
public interface IAsyncQueryableService
|
||||||
{
|
{
|
||||||
|
IEnumerable<IAsyncQueryableHandlerService> Handlers { get; }
|
||||||
|
|
||||||
IAsyncQueryableHandlerService GetAsyncQueryableHandler<T>(IQueryable<T> queryable);
|
IAsyncQueryableHandlerService GetAsyncQueryableHandler<T>(IQueryable<T> queryable);
|
||||||
|
|
||||||
Task<T> FirstOrDefaultAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken));
|
Task<T> FirstOrDefaultAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken));
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
||||||
<RepositoryType>github</RepositoryType>
|
<RepositoryType>github</RepositoryType>
|
||||||
<PackageTags>powered,soft,orm,db,context,ef,ef6,efcore,factory</PackageTags>
|
<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;r=g&amp;d=retro</PackageIconUrl>
|
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||||
<Product>PoweredSoft.Data.Core</Product>
|
<Product>PoweredSoft.Data.Core</Product>
|
||||||
<Description>Library to abstract orm.</Description>
|
<Description>Library to abstract orm.</Description>
|
||||||
|
@ -8,6 +8,8 @@ using PoweredSoft.Test.Mock;
|
|||||||
using PoweredSoft.Data.Core;
|
using PoweredSoft.Data.Core;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using PoweredSoft.Data.MongoDB;
|
||||||
|
|
||||||
namespace PoweredSoft.Data.EntityFrameworkCore.Test
|
namespace PoweredSoft.Data.EntityFrameworkCore.Test
|
||||||
{
|
{
|
||||||
@ -35,5 +37,22 @@ namespace PoweredSoft.Data.EntityFrameworkCore.Test
|
|||||||
var shouldBeEfCoreHandler = service.GetAsyncQueryableHandler(efCoreOrders);
|
var shouldBeEfCoreHandler = service.GetAsyncQueryableHandler(efCoreOrders);
|
||||||
Assert.Equal(efCoreHandler, shouldBeEfCoreHandler);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
||||||
<RepositoryType>github</RepositoryType>
|
<RepositoryType>github</RepositoryType>
|
||||||
<PackageTags>powered,soft,orm,db,context,ef,ef6,efcore,factory</PackageTags>
|
<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;r=g&amp;d=retro</PackageIconUrl>
|
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||||
<Product>PoweredSoft.Data.EntityFrameworkCore</Product>
|
<Product>PoweredSoft.Data.EntityFrameworkCore</Product>
|
||||||
<Description>the abstraction implementation for EF Core.</Description>
|
<Description>the abstraction implementation for EF Core.</Description>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
||||||
<RepositoryType>github</RepositoryType>
|
<RepositoryType>github</RepositoryType>
|
||||||
<PackageTags>powered,soft,async,queryable,handler</PackageTags>
|
<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;r=g&amp;d=retro</PackageIconUrl>
|
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||||
<Product>PoweredSoft.Data.MongoDB</Product>
|
<Product>PoweredSoft.Data.MongoDB</Product>
|
||||||
<Description>the abstraction implementation for MongoDB.</Description>
|
<Description>the abstraction implementation for MongoDB.</Description>
|
||||||
|
@ -10,12 +10,12 @@ namespace PoweredSoft.Data
|
|||||||
{
|
{
|
||||||
public class AsyncQueryableService : IAsyncQueryableService
|
public class AsyncQueryableService : IAsyncQueryableService
|
||||||
{
|
{
|
||||||
public AsyncQueryableService(IEnumerable<IAsyncQueryableHandlerService> asyncQueryableFactories)
|
public IEnumerable<IAsyncQueryableHandlerService> Handlers { get; }
|
||||||
{
|
|
||||||
AsyncQueryableFactories = asyncQueryableFactories;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<IAsyncQueryableHandlerService> AsyncQueryableFactories { get; }
|
public AsyncQueryableService(IEnumerable<IAsyncQueryableHandlerService> handlers)
|
||||||
|
{
|
||||||
|
Handlers = handlers;
|
||||||
|
}
|
||||||
|
|
||||||
public Task<int> CountAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken))
|
public Task<int> CountAsync<T>(IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
=> GetAsyncQueryableHandlerOrThrow(queryable).CountAsync(queryable, cancellationToken);
|
=> GetAsyncQueryableHandlerOrThrow(queryable).CountAsync(queryable, cancellationToken);
|
||||||
@ -37,7 +37,7 @@ namespace PoweredSoft.Data
|
|||||||
|
|
||||||
public IAsyncQueryableHandlerService GetAsyncQueryableHandler<T>(IQueryable<T> queryable)
|
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;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
<RepositoryUrl>https://github.com/PoweredSoft/Data</RepositoryUrl>
|
||||||
<RepositoryType>github</RepositoryType>
|
<RepositoryType>github</RepositoryType>
|
||||||
<PackageTags>async,queryable,handler,service,di</PackageTags>
|
<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;r=g&amp;d=retro</PackageIconUrl>
|
<PackageIconUrl>https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro</PackageIconUrl>
|
||||||
<Product>PoweredSoft.Data</Product>
|
<Product>PoweredSoft.Data</Product>
|
||||||
<Description>Library to abstract orm.</Description>
|
<Description>Library to abstract orm.</Description>
|
||||||
|
Loading…
Reference in New Issue
Block a user