updating powered soft data services and .net core to 2.2.0
This commit is contained in:
parent
22563bdab9
commit
1d2b0e17b7
@ -25,6 +25,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.Data.Core", "..
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.Data.EntityFrameworkCore", "..\Data\PoweredSoft.Data.EntityFrameworkCore\PoweredSoft.Data.EntityFrameworkCore.csproj", "{9D3ED339-8AF2-44B7-9AC5-720A0AC6C2FD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.Data", "..\Data\PoweredSoft.Data\PoweredSoft.Data.csproj", "{1A039A0F-1D09-4CAC-B86F-5F16DC026375}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -63,6 +65,10 @@ Global
|
||||
{9D3ED339-8AF2-44B7-9AC5-720A0AC6C2FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9D3ED339-8AF2-44B7-9AC5-720A0AC6C2FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9D3ED339-8AF2-44B7-9AC5-720A0AC6C2FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1A039A0F-1D09-4CAC-B86F-5F16DC026375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1A039A0F-1D09-4CAC-B86F-5F16DC026375}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1A039A0F-1D09-4CAC-B86F-5F16DC026375}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1A039A0F-1D09-4CAC-B86F-5F16DC026375}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using PoweredSoft.Data;
|
||||
using PoweredSoft.DynamicQuery.AspNetCore.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -11,6 +12,7 @@ namespace PoweredSoft.DynamicQuery.AspNetCore
|
||||
{
|
||||
public static IMvcBuilder AddPoweredSoftDynamicQuery(this IMvcBuilder builder)
|
||||
{
|
||||
builder.Services.AddPoweredSoftDataServices();
|
||||
builder.Services.AddPoweredSoftDynamicQuery();
|
||||
var serviceProvider = builder.Services.BuildServiceProvider();
|
||||
builder.AddJsonOptions(o =>
|
||||
|
@ -21,8 +21,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using PoweredSoft.Data.EntityFrameworkCore;
|
||||
using PoweredSoft.Data;
|
||||
using PoweredSoft.Data.EntityFrameworkCore;
|
||||
using PoweredSoft.DynamicQuery.Core;
|
||||
using PoweredSoft.DynamicQuery.Test.Mock;
|
||||
using System;
|
||||
@ -21,7 +22,7 @@ namespace PoweredSoft.DynamicQuery.Test
|
||||
var queryable = ctx.Items.AsQueryable();
|
||||
|
||||
// query handler that is empty should be the same as running to list.
|
||||
var aqf = new AsyncQueryableFactory();
|
||||
var aqf = new AsyncQueryableService(new[] { new AsyncQueryableHandlerService() });
|
||||
var criteria = new QueryCriteria();
|
||||
var queryHandler = new QueryHandlerAsync(aqf);
|
||||
var result = await queryHandler.ExecuteAsync(queryable, criteria);
|
||||
@ -61,8 +62,8 @@ namespace PoweredSoft.DynamicQuery.Test
|
||||
new Aggregate { Type = AggregateType.Avg, Path = "PriceAtTheTime"}
|
||||
}
|
||||
};
|
||||
|
||||
var queryHandler = new QueryHandlerAsync(new AsyncQueryableFactory());
|
||||
var asyncService = new AsyncQueryableService(new[] { new AsyncQueryableHandlerService() });
|
||||
var queryHandler = new QueryHandlerAsync(asyncService);
|
||||
var result = await queryHandler.ExecuteAsync(ctx.OrderItems, criteria);
|
||||
var groups = result.Data.Cast<IGroupQueryResult>().ToList();
|
||||
|
||||
@ -109,7 +110,8 @@ namespace PoweredSoft.DynamicQuery.Test
|
||||
}
|
||||
};
|
||||
|
||||
var queryHandler = new QueryHandlerAsync(new AsyncQueryableFactory());
|
||||
var asyncService = new AsyncQueryableService(new[] { new AsyncQueryableHandlerService() });
|
||||
var queryHandler = new QueryHandlerAsync(asyncService);
|
||||
var result = await queryHandler.ExecuteAsync(ctx.Items, criteria);
|
||||
Assert.Equal(resultShouldMatch, result.Data);
|
||||
});
|
||||
@ -128,7 +130,8 @@ namespace PoweredSoft.DynamicQuery.Test
|
||||
criteria.Page = 2;
|
||||
criteria.PageSize = 5;
|
||||
|
||||
var queryHandler = new QueryHandlerAsync(new AsyncQueryableFactory());
|
||||
var asyncService = new AsyncQueryableService(new[] { new AsyncQueryableHandlerService() });
|
||||
var queryHandler = new QueryHandlerAsync(asyncService);
|
||||
var result = await queryHandler.ExecuteAsync(ctx.OrderItems, criteria);
|
||||
Assert.Equal(resultShouldMatch, result.Data);
|
||||
});
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Data\PoweredSoft.Data.Core\PoweredSoft.Data.Core.csproj" />
|
||||
<ProjectReference Include="..\..\Data\PoweredSoft.Data\PoweredSoft.Data.csproj" />
|
||||
<ProjectReference Include="..\..\DynamicLinq\PoweredSoft.DynamicLinq\PoweredSoft.DynamicLinq.csproj" />
|
||||
<ProjectReference Include="..\PoweredSoft.DynamicQuery.Core\PoweredSoft.DynamicQuery.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -11,13 +11,15 @@ namespace PoweredSoft.DynamicQuery
|
||||
{
|
||||
public class QueryHandlerAsync : QueryHandlerBase, IQueryHandlerAsync
|
||||
{
|
||||
public IAsyncQueryableFactory AsyncQueryableFactory { get; }
|
||||
internal MethodInfo ExecuteAsyncGeneric = typeof(QueryHandlerAsync).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).First(t => t.Name == "ExecuteAsync" && t.IsGenericMethod);
|
||||
|
||||
public IAsyncQueryableService AsyncQueryableService { get; }
|
||||
|
||||
internal Task<IQueryExecutionResult> ExecuteAsyncReflected(CancellationToken cancellationToken) => (Task<IQueryExecutionResult>)ExecuteAsyncGeneric.MakeGenericMethod(QueryableUnderlyingType).Invoke(this, new object[] { cancellationToken });
|
||||
|
||||
public QueryHandlerAsync(IAsyncQueryableFactory asyncQueryableFactory)
|
||||
public QueryHandlerAsync(IAsyncQueryableService asyncQueryableService)
|
||||
{
|
||||
AsyncQueryableFactory = asyncQueryableFactory;
|
||||
AsyncQueryableService = asyncQueryableService;
|
||||
}
|
||||
|
||||
protected virtual Task<IQueryExecutionResult> ExecuteAsync<T>(CancellationToken cancellationToken = default(CancellationToken))
|
||||
@ -40,7 +42,7 @@ namespace PoweredSoft.DynamicQuery
|
||||
var queryableAfterFilters = CurrentQueryable;
|
||||
|
||||
// async.
|
||||
result.TotalRecords = await this.AsyncQueryableFactory.LongCountAsync((IQueryable<T>)queryableAfterFilters, cancellationToken);
|
||||
result.TotalRecords = await this.AsyncQueryableService.LongCountAsync((IQueryable<T>)queryableAfterFilters, cancellationToken);
|
||||
CalculatePageCount(result);
|
||||
|
||||
// intercept groups in advance to avoid doing it more than once :)
|
||||
@ -65,7 +67,7 @@ namespace PoweredSoft.DynamicQuery
|
||||
});
|
||||
|
||||
// loop through the grouped records.
|
||||
var groupRecords = await AsyncQueryableFactory.ToListAsync(CurrentQueryable.Cast<DynamicClass>(), cancellationToken);
|
||||
var groupRecords = await AsyncQueryableService.ToListAsync(CurrentQueryable.Cast<DynamicClass>(), cancellationToken);
|
||||
|
||||
// now join them into logical collections
|
||||
result.Data = RecursiveRegroup<T>(groupRecords, aggregateResults, Criteria.Groups.First());
|
||||
@ -82,7 +84,7 @@ namespace PoweredSoft.DynamicQuery
|
||||
IQueryable<T> afterFilterQueryable = (IQueryable<T>)CurrentQueryable;
|
||||
|
||||
// total records.
|
||||
result.TotalRecords = await AsyncQueryableFactory.LongCountAsync(afterFilterQueryable, cancellationToken);
|
||||
result.TotalRecords = await AsyncQueryableService.LongCountAsync(afterFilterQueryable, cancellationToken);
|
||||
CalculatePageCount(result);
|
||||
|
||||
// sorts and paging.
|
||||
@ -90,7 +92,7 @@ namespace PoweredSoft.DynamicQuery
|
||||
ApplyPaging<T>();
|
||||
|
||||
// data.
|
||||
var entities = await AsyncQueryableFactory.ToListAsync(((IQueryable<T>)CurrentQueryable), cancellationToken);
|
||||
var entities = await AsyncQueryableService.ToListAsync(((IQueryable<T>)CurrentQueryable), cancellationToken);
|
||||
var records = InterceptConvertTo<T>(entities);
|
||||
result.Data = records;
|
||||
|
||||
@ -105,7 +107,7 @@ namespace PoweredSoft.DynamicQuery
|
||||
return null;
|
||||
|
||||
IQueryable selectExpression = CreateTotalAggregateSelectExpression<T>(queryableAfterFilters);
|
||||
var aggregateResult = await AsyncQueryableFactory.FirstOrDefaultAsync(selectExpression.Cast<DynamicClass>());
|
||||
var aggregateResult = await AsyncQueryableService.FirstOrDefaultAsync(selectExpression.Cast<DynamicClass>());
|
||||
return MaterializeCalculateTotalAggregateResult(aggregateResult);
|
||||
}
|
||||
|
||||
@ -120,7 +122,7 @@ namespace PoweredSoft.DynamicQuery
|
||||
{
|
||||
IQueryable selectExpression = CreateFetchAggregateSelectExpression<T>(fg, previousGroups);
|
||||
var selectExpressionCasted = selectExpression.Cast<DynamicClass>();
|
||||
var aggregateResult = AsyncQueryableFactory.ToListAsync(selectExpressionCasted, cancellationToken);
|
||||
var aggregateResult = AsyncQueryableService.ToListAsync(selectExpressionCasted, cancellationToken);
|
||||
previousGroups.Add(fg);
|
||||
return aggregateResult;
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user