public async Task <TResult> MaxAsync <TResult>(Expression <Func <T, TResult> > selector)
        {
            var newSource = _source.Select(selector);
            var results   = await GetStatisDataAsync <TResult>(x => EntityFrameworkQueryableExtensions.MaxAsync((dynamic)x), newSource);

            return(results.Max());
        }
Beispiel #2
0
 public Task <TResult> MaxAsync <TSource, TResult>(IQueryable <TSource> source, Expression <Func <TSource, TResult> > selector, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(EntityFrameworkQueryableExtensions.MaxAsync(source, selector, cancellationToken));
 }
Beispiel #3
0
 public Task <TSource> MaxAsync <TSource>(IQueryable <TSource> source, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(EntityFrameworkQueryableExtensions.MaxAsync(source, cancellationToken));
 }
        public async Task Extension_methods_validate_arguments()
        {
            // ReSharper disable AssignNullToNotNullAttribute

            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().FirstAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().FirstOrDefaultAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().SingleAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().SingleOrDefaultAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.ContainsAsync(null, 1));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.ContainsAsync(null, 1, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AnyAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AnyAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().AnyAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AllAsync <int>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AllAsync <int>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("predicate", () => Source().AllAsync(null));
            await ArgumentNullTest("predicate", () => Source().AllAsync(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.CountAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.CountAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().CountAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("predicate", () => Source().LongCountAsync(null));
            await ArgumentNullTest("predicate", () => Source().LongCountAsync(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int, bool>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int, bool>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source().MinAsync <int, bool>(null));
            await ArgumentNullTest("selector", () => Source().MinAsync <int, bool>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int, bool>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int, bool>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source().MaxAsync <int, bool>(null));
            await ArgumentNullTest("selector", () => Source().MaxAsync <int, bool>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <int>().SumAsync((Expression <Func <int, int> >)null));
            await ArgumentNullTest("selector", () => Source <int?>().SumAsync((Expression <Func <int?, int> >)null));
            await ArgumentNullTest("selector", () => Source <long>().SumAsync((Expression <Func <long, int> >)null));
            await ArgumentNullTest("selector", () => Source <long?>().SumAsync((Expression <Func <long?, int> >)null));
            await ArgumentNullTest("selector", () => Source <float>().SumAsync((Expression <Func <float, int> >)null));
            await ArgumentNullTest("selector", () => Source <float?>().SumAsync((Expression <Func <float?, int> >)null));
            await ArgumentNullTest("selector", () => Source <double>().SumAsync((Expression <Func <double, int> >)null));
            await ArgumentNullTest("selector", () => Source <double?>().SumAsync((Expression <Func <double?, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal>().SumAsync((Expression <Func <decimal, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal?>().SumAsync((Expression <Func <decimal?, int> >)null));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <int>().AverageAsync((Expression <Func <int, int> >)null));
            await ArgumentNullTest("selector", () => Source <int>().AverageAsync((Expression <Func <int, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <int?>().AverageAsync((Expression <Func <int?, int> >)null));
            await ArgumentNullTest("selector", () => Source <int?>().AverageAsync((Expression <Func <int?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <long>().AverageAsync((Expression <Func <long, int> >)null));
            await ArgumentNullTest("selector", () => Source <long>().AverageAsync((Expression <Func <long, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <long?>().AverageAsync((Expression <Func <long?, int> >)null));
            await ArgumentNullTest("selector", () => Source <long?>().AverageAsync((Expression <Func <long?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <float>().AverageAsync((Expression <Func <float, int> >)null));
            await ArgumentNullTest("selector", () => Source <float>().AverageAsync((Expression <Func <float, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <float?>().AverageAsync((Expression <Func <float?, int> >)null));
            await ArgumentNullTest("selector", () => Source <float?>().AverageAsync((Expression <Func <float?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <double>().AverageAsync((Expression <Func <double, int> >)null));
            await ArgumentNullTest("selector", () => Source <double>().AverageAsync((Expression <Func <double, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <double?>().AverageAsync((Expression <Func <double?, int> >)null));
            await ArgumentNullTest("selector", () => Source <double?>().AverageAsync((Expression <Func <double?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <decimal>().AverageAsync((Expression <Func <decimal, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal>().AverageAsync((Expression <Func <decimal, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <decimal?>().AverageAsync((Expression <Func <decimal?, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal?>().AverageAsync((Expression <Func <decimal?, int> >)null, new CancellationToken()));

            // ReSharper restore AssignNullToNotNullAttribute
        }
Beispiel #5
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.MaxAsync{TSource, TResult}(IQueryable{TSource}, Expression{Func{TSource, TResult}}, CancellationToken)"/>
 public static Task <TResult> MaxAsyncEF <TSource, TResult>(
     this IQueryable <TSource> source,
     Expression <Func <TSource, TResult> > selector,
     CancellationToken cancellationToken = default)
 => EntityFrameworkQueryableExtensions.MaxAsync(source, selector, cancellationToken);
Beispiel #6
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.MaxAsync{TSource}(IQueryable{TSource}, CancellationToken)"/>
 public static Task <TSource> MaxAsyncEF <TSource>(
     this IQueryable <TSource> source,
     CancellationToken cancellationToken = default)
 => EntityFrameworkQueryableExtensions.MaxAsync(source, cancellationToken);
Beispiel #7
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.MaxAsync{TSource, TResult}(IQueryable{TSource}, Expression{Func{TSource, TResult}}, CancellationToken)"/>
 public Task <TResult> MaxAsync <TSource, TResult>(
     IQueryable <TSource> source,
     Expression <Func <TSource, TResult> > selector,
     CancellationToken token)
 => EntityFrameworkQueryableExtensions.MaxAsync(source, selector, token);
Beispiel #8
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.MaxAsync{TSource}(IQueryable{TSource}, CancellationToken)"/>
 public Task <TSource> MaxAsync <TSource>(
     IQueryable <TSource> source,
     CancellationToken token)
 => EntityFrameworkQueryableExtensions.MaxAsync(source, token);
 public Task <TResult> MaxAsync <TSource, TResult>(IQueryable <TSource> source, Expression <Func <TSource, TResult> > selector)
 {
     return(EntityFrameworkQueryableExtensions.MaxAsync(source, selector));
 }
Beispiel #10
0
        public async Task <T> MaxAsync()
        {
            var results = await GetGenericMergeEngine(async queryable => await EntityFrameworkQueryableExtensions.MaxAsync((IQueryable <T>)queryable));

            return(results.Max());
        }