Пример #1
0
        public async Task CoinReset()
        {
            //Check if event happened today
            var didHappen = await EntityFrameworkQueryableExtensions.AnyAsync(_db.Events, ev => ev.Date.Day == DateTime.Today.Day &&
                                                                              ev.Date.Month == DateTime.Today.Month &&
                                                                              ev.Date.Year == DateTime.Today.Year &&
                                                                              ev.Type == EventType.Coins);

            if (didHappen)
            {
                return;
            }

            //get users
            var users = await EntityFrameworkQueryableExtensions.ToListAsync(_db.UserData);

            var newUsers = users.Select(c => { c.UserDaily = false; return(c); }).ToList();

            _db.UserData.UpdateRange(newUsers);
            await _db.SaveChangesAsync();

            //Add event
            await AddEvent(EventType.Coins);

            _logger.LogInformation("Coin reset");
        }
        public async Task <bool> AnyAsync(Expression <Func <T, bool> > predicate)
        {
            var newSource = _source.Where(predicate);

            return((await GetStatisDataAsync <bool>(x => EntityFrameworkQueryableExtensions.AnyAsync((dynamic)x), newSource))
                   .Any(x => x == true));
        }
Пример #3
0
    public async Task <bool> Any(Expression <Func <T, bool> > filter = default)
    {
        if (filter == default)
        {
            return(await EntityFrameworkQueryableExtensions.AnyAsync(_dbContext.Set <T>()));
        }

        return(await _dbContext.Set <T>().AnyAsync(filter));
    }
Пример #4
0
        public virtual async Task <bool> AnyAsync(Expression <Func <TEntity, bool> > whereExpression, bool writeDb = false, CancellationToken cancellationToken = default)
        {
            var dbSet = DbContext.Set <TEntity>().AsNoTracking();

            if (writeDb)
            {
                dbSet = dbSet.TagWith(EfCoreConsts.MAXSCALE_ROUTE_TO_MASTER);
            }
            return(await EntityFrameworkQueryableExtensions.AnyAsync(dbSet, whereExpression, cancellationToken));
        }
Пример #5
0
        public async Task <bool> RegisterChat(ModelContainer db, long chatId, string phoneNumber)
        {
            if (await EntityFrameworkQueryableExtensions.AnyAsync(db.TelegramChats, x => x.ChatId == chatId && x.Number == phoneNumber))
            {
                return(false);
            }

            db.TelegramChats.Add(new TelegramChat {
                ChatId = chatId, Number = phoneNumber
            });
            await db.SaveChangesAsync();

            return(true);
        }
        public async Task TestAsyncMethods([Values(true, false)] bool enableFilter)
        {
            using (var ctx = CreateContext(enableFilter))
            {
                var query = ctx.Products.AsQueryable().Where(p => p.ProductName.Contains("a"));

                var expectedArray = await query.ToArrayAsync();

                var expectedDictionary = await query.ToDictionaryAsync(p => p.ProductId);

                var expectedAny = await query.AnyAsync();

                var byList = await EntityFrameworkQueryableExtensions.ToListAsync(query.ToLinqToDB());

                var byArray = await EntityFrameworkQueryableExtensions.ToArrayAsync(query.ToLinqToDB());

                var byDictionary = await EntityFrameworkQueryableExtensions.ToDictionaryAsync(query.ToLinqToDB(), p => p.ProductId);

                var any = await EntityFrameworkQueryableExtensions.AnyAsync(query.ToLinqToDB());
            }
        }
Пример #7
0
        public async Task TestAsyncMethods()
        {
            using (var ctx = CreateAdventureWorksContext())
            {
                var query = ctx.Products.AsQueryable().Where(p => p.Name.Contains("a"));

                var expected = await query.ToArrayAsync();

                var expectedDictionary = await query.ToDictionaryAsync(p => p.ProductID);

                var expectedAny = await query.AnyAsync();

                var byList = await EntityFrameworkQueryableExtensions.ToListAsync(query.ToLinqToDB());

                var byArray = await EntityFrameworkQueryableExtensions.ToArrayAsync(query.ToLinqToDB());

                var byDictionary = await EntityFrameworkQueryableExtensions.ToDictionaryAsync(query.ToLinqToDB(), p => p.ProductID);

                var any = await EntityFrameworkQueryableExtensions.AnyAsync(query.ToLinqToDB());
            }
        }
Пример #8
0
        public async Task <int> CreateIfNotExist <T>(Expression <Func <T, bool> > matchCondition,
                                                     Expression <Func <T> > creator) where T : class, IEntity, new()
        {
            //todo create batch
            if (!(creator.Body is MemberInitExpression))
            {
                throw new InvalidOperationException(
                          $"setter must be lambda expression with init entity body, current: [{creator}]");
            }
            var existance = await EntityFrameworkQueryableExtensions.AnyAsync(_context.Set <T>(), matchCondition);

            if (existance)
            {
                return(0);
            }
            var newEntity = new T();
            var action    = CreateUpdateAction(creator);

            action.Invoke(newEntity);
            SetServiceColumnForCreate(newEntity);
            _context.Add(newEntity);
            return(await _context.SaveChangesAsync());
        }
Пример #9
0
        public async Task EggplantReset()
        {
            var didHappen = await EntityFrameworkQueryableExtensions.AnyAsync(_db.Events, ev => ev.Date.Day == DateTime.Today.Day &&
                                                                              ev.Date.Month == DateTime.Today.Month &&
                                                                              ev.Date.Year == DateTime.Today.Year &&
                                                                              ev.Type == EventType.EggplantReset);

            if (didHappen)
            {
                return;
            }

            var users = await EntityFrameworkQueryableExtensions.ToListAsync(_db.UserData);

            var newUsers = users.Select(c => { c.EggplantDaily = false; return(c); }).ToList();

            _db.UserData.UpdateRange(newUsers);
            await _db.SaveChangesAsync();

            await AddEvent(EventType.EggplantReset);

            _logger.LogInformation("Eggplant reset");
        }
Пример #10
0
 public Task <bool> AnyAsync <T>(IQueryable <T> query)
 {
     return(EntityFrameworkQueryableExtensions.AnyAsync(query));
 }
 public Task <bool> AnyAsync <TSource>(
     IQueryable <TSource> source,
     CancellationToken cancellationToken = default) =>
 EntityFrameworkQueryableExtensions.AnyAsync(source, cancellationToken);
Пример #12
0
 public async Task <bool> AnyAsync(CancellationToken ct = default)
 {
     await using var context = new RiftContext();
     return(await EntityFrameworkQueryableExtensions.AnyAsync(context.ActiveEvents, ct));
 }
Пример #13
0
 public async Task <bool> CheckRegister(ModelContainer db, long chatId, string phoneNumber)
 {
     return(await EntityFrameworkQueryableExtensions.AnyAsync(db.TelegramChats, x => x.ChatId == chatId && x.Number == phoneNumber));
 }
Пример #14
0
        public async Task BirthdayEvent()
        {
            //check if event happened today already
            var didHappen = await EntityFrameworkQueryableExtensions.AnyAsync(_db.Events, ev => ev.Date.Day == DateTime.Today.Day &&
                                                                              ev.Date.Month == DateTime.Today.Month &&
                                                                              ev.Date.Year == DateTime.Today.Year &&
                                                                              ev.Type == EventType.BirthdayEvent);

            if (didHappen)
            {
                return;
            }

            List <UserData> users = await System.Linq.AsyncEnumerable
                                    .Where <UserData>(_db.UserData.Include(entity => entity.BirthdayDate)
                                                      .ToAsyncEnumerable(), user => user.BirthdayDate != null &&
                                                      user.BirthdayDate.DoDisplay == true &&
                                                      user.BirthdayDate.Date.Day == DateTime.Today.Day &&
                                                      user.BirthdayDate.Date.Month == DateTime.Today.Month)
                                    .ToListAsync();

            if (users == null)
            {
                return;
            }

            foreach (var user in users)
            {
                //check if user wants to display his birthday
                if (!user.BirthdayDate.DoDisplay)
                {
                    return;
                }

                SocketUser discordUser = _client.GetUser(user.UserId);

                foreach (var guild in discordUser.MutualGuilds)
                {
                    var guildSetting = await Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(_db.ServersSettings, x => x.ServerId == guild.Id);

                    //check if server allows birthdays
                    if (!guildSetting.DoBrithday)
                    {
                        continue;
                    }

                    if (guildSetting.BirthdayRoom == 0)
                    {
                        await guild.DefaultChannel.SendMessageAsync($"<@{user.UserId}> has birthday today! You can wish him his happy cake day!");
                    }
                    else
                    {
                        try
                        {
                            await guild.GetTextChannel(guildSetting.BirthdayRoom).SendMessageAsync($"<@{user.UserId}> has birthday today! You can wish him his happy cake day!");
                        }
                        catch (Exception e)
                        {
                            await guild.DefaultChannel.SendMessageAsync("Something went wrong with birthday room, could you check if the ID of it is correct?\nYou can use $GetChannelID command to see if its correct and $ServerSettings to see settings");
                        }
                    }
                }
            }

            //Add event
            await AddEvent(EventType.BirthdayEvent);

            _logger.LogInformation("Birthday event");
        }
Пример #15
0
 public async Task <bool> AnyAsync()
 {
     return((await GetGenericMergeEngine(x => EntityFrameworkQueryableExtensions.AnyAsync((IQueryable <T>)x)))
            .Any(o => o));
 }
Пример #16
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.AnyAsync{TSource}(IQueryable{TSource}, Expression{Func{TSource, bool}}, CancellationToken)"/>
 public static Task <bool> AnyAsyncEF <TSource>(
     this IQueryable <TSource> source,
     Expression <Func <TSource, bool> > predicate,
     CancellationToken cancellationToken = default)
 => EntityFrameworkQueryableExtensions.AnyAsync(source, predicate, cancellationToken);
Пример #17
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.AnyAsync{TSource}(IQueryable{TSource}, Expression{Func{TSource, bool}}, CancellationToken)"/>
 public Task <bool> AnyAsync <TSource>(
     IQueryable <TSource> source,
     Expression <Func <TSource, bool> > predicate,
     CancellationToken token)
 => EntityFrameworkQueryableExtensions.AnyAsync(source, predicate, token);
Пример #18
0
        public async Task Invoke(SocketUserMessage msg)
        {
            var args          = msg.Content.Trim().Split(' ').Skip(1).ToList();
            var rolesToManage = msg.MentionedRoles.Where(x => !x.IsEveryone && !x.IsManaged).ToList();
            var user          = (SocketGuildUser)msg.Author;
            var guild         = user.Guild;

            if (rolesToManage.Count > 0)
            {
                var existingRoles = new List <SocketRole>();
                var newRoles      = new List <SocketRole>();
                foreach (var role in msg.MentionedRoles)
                {
                    if (await EntityFrameworkQueryableExtensions.AnyAsync(_context.ManagedRoles, x => x.GuildId == guild.Id && x.RoleId == role.Id))
                    {
                        existingRoles.Add(role);
                        continue;
                    }
                    var managedRole = new ManagedRole()
                    {
                        GuildId = guild.Id,
                        RoleId  = role.Id
                    };
                    await _context.ManagedRoles.AddAsync(managedRole);

                    newRoles.Add(role);
                }

                await _context.SaveChangesAsync();

                if (existingRoles.Any())
                {
                    var existingResponse =
                        $"Already managing: {string.Join(", ", existingRoles.Select(x => x.Name))}";
                    await msg.Channel.SendMessageAsync(existingResponse);
                }

                var successResponse =
                    $"Now managing roles: {string.Join(", ", newRoles.Select(x => x.Name))}";
                await msg.Channel.SendMessageAsync(successResponse);
            }
            else if (args[0].ToLower() == "create" && args.Count > 1)
            {
                var newRoles = args.Skip(1);
                foreach (var newRole in newRoles)
                {
                    var role = await guild.CreateRoleAsync(newRole, null, null, false, false);

                    var managedRole = new ManagedRole()
                    {
                        GuildId = guild.Id,
                        RoleId  = role.Id
                    };
                    await _context.ManagedRoles.AddAsync(managedRole);
                }

                await _context.SaveChangesAsync();
            }
            else
            {
                await msg.Channel.SendMessageAsync("Please mention one or more roles");
            }
        }
        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
        }
Пример #20
0
 public Task <bool> AnyAsync <T>(IQueryable <T> query, Expression <Func <T, bool> > predicate)
 {
     return(EntityFrameworkQueryableExtensions.AnyAsync(query, predicate));
 }
 public static async Task <bool> AnyAsync <TSource>(this IQueryable <TSource> source, Expression <Func <TSource, bool> > predicate)
     where TSource : Entity
 {
     return(await EntityFrameworkQueryableExtensions.AnyAsync(source, predicate));
 }
Пример #22
0
 public Task <bool> AnyAsync <TSource>(IQueryable <TSource> source, Expression <Func <TSource, bool> > predicate, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(EntityFrameworkQueryableExtensions.AnyAsync(source, predicate, cancellationToken));
 }
Пример #23
0
 public static Task <bool> AnyAsyncEF <TSource>(
     this IQueryable <TSource> source,
     CancellationToken token = default)
 => EntityFrameworkQueryableExtensions.AnyAsync(source, token);