Exemplo n.º 1
0
        public void AndAlso_GivenFunc_ReturnsExpectedResult()
        {
            // Arrange
            Func <Person, bool> givenNameStartsWithN         = p => p.GivenName.StartsWith("N", StringComparison.OrdinalIgnoreCase);
            Func <Person, bool> favoriteBookGenreIsAdventure = p => p.FavoriteBook.Genre == Genre.Adventure;

            // Act
            var result = People.Where(givenNameStartsWithN.AndAlso(favoriteBookGenreIsAdventure));

            // Assert
            Assert.AreEqual(1, result.Count());
        }
        public virtual IEnumerable <TEntity> Get(List <Func <TEntity, bool> > filtros, string includeProperties, Int32 NroPagina = 0, Int32 RegistrosPorPagina = int.MaxValue)
        {
            //Func<TEntity, bool> filter = x => x.Id > 0;
            Func <TEntity, bool> filter = x => x.ToString().Length > 0;

            foreach (var item in filtros)
            {
                filter = filter.AndAlso(item);
            }

            IQueryable <TEntity> query = dbSet;

            foreach (var includeProperty in includeProperties.Split
                         (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                query = query.Include(includeProperty);
            }
            return(query.AsNoTracking().Where(filter).Skip(NroPagina * RegistrosPorPagina).Take(RegistrosPorPagina));
        }