Async seems to work very well :)

This commit is contained in:
David Lebee
2018-12-06 23:08:16 -06:00
parent 23b45a00ac
commit ce07c3f6d2
4 changed files with 145 additions and 3 deletions
@@ -12,7 +12,7 @@ namespace PoweredSoft.DynamicQuery
public class QueryHandlerAsync : QueryHandlerBase, IQueryHandlerAsync
{
public IAsyncQueryableFactory AsyncQueryableFactory { get; }
internal MethodInfo ExecuteAsyncGeneric = typeof(QueryHandler).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).First(t => t.Name == "ExecuteAsync" && t.IsGenericMethod);
internal MethodInfo ExecuteAsyncGeneric = typeof(QueryHandlerAsync).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).First(t => t.Name == "ExecuteAsync" && t.IsGenericMethod);
internal Task<IQueryExecutionResult> ExecuteAsyncReflected(CancellationToken cancellationToken) => (Task<IQueryExecutionResult>)ExecuteAsyncGeneric.MakeGenericMethod(QueryableUnderlyingType).Invoke(this, new object[] { cancellationToken });
public QueryHandlerAsync(IAsyncQueryableFactory asyncQueryableFactory)
@@ -20,7 +20,7 @@ namespace PoweredSoft.DynamicQuery
AsyncQueryableFactory = asyncQueryableFactory;
}
public Task<IQueryExecutionResult> ExecuteAsync<T>(IQueryable queryable, IQueryCriteria criteria, CancellationToken cancellationToken = default(CancellationToken))
protected virtual Task<IQueryExecutionResult> ExecuteAsync<T>(CancellationToken cancellationToken = default(CancellationToken))
{
CommonBeforeExecute<T>();
return HasGrouping ? ExecuteAsyncGrouping<T>(cancellationToken) : ExecuteAsyncNoGrouping<T>(cancellationToken);
@@ -120,7 +120,7 @@ namespace PoweredSoft.DynamicQuery
{
IQueryable selectExpression = CreateFetchAggregateSelectExpression<T>(fg, previousGroups);
var selectExpressionCasted = selectExpression.Cast<DynamicClass>();
var aggregateResult = AsyncQueryableFactory.ToListAsync<DynamicClass>(selectExpressionCasted, cancellationToken);
var aggregateResult = AsyncQueryableFactory.ToListAsync(selectExpressionCasted, cancellationToken);
previousGroups.Add(fg);
return aggregateResult;
}));