コード例 #1
0
        public List<ClienteEntity> Lista(int limite, int offset, ClientePesquisaModel pesquisa)
        {

            var query = AsQueryable;
            if (pesquisa != null)
            {
                if (!string.IsNullOrEmpty(pesquisa.Nome))
                {
                    query = query.Where(x => x.Nome.Contains(pesquisa.Nome));
                }

                if (!string.IsNullOrEmpty(pesquisa.Codigo))
                {
                    query = query.Where(x => x.Codigo.Contains(pesquisa.Codigo));
                }

                if (!string.IsNullOrEmpty(pesquisa.Cpf))
                {
                    query = query.Where(x => x.Cpf.Contains(pesquisa.Cpf));
                }
            }
            query = query.OrderByDescending(x => x.DataCadastro).Skip(offset).Take(limite);

            return query.ToList();
        }
コード例 #2
0
        public int TotalRegistros(ClientePesquisaModel pesquisa)
        {
            var query = AsQueryable;

            if (pesquisa != null)
            {
                if (!string.IsNullOrEmpty(pesquisa.Nome))
                {
                    query = query.Where(x => x.Nome.Contains(pesquisa.Nome));
                }

                if (!string.IsNullOrEmpty(pesquisa.Codigo))
                {
                    query = query.Where(x => x.Codigo.Contains(pesquisa.Codigo));
                }

                if (!string.IsNullOrEmpty(pesquisa.Cpf))
                {
                    query = query.Where(x => x.Cpf.Contains(pesquisa.Cpf));
                }
            }

            return query.Count();
        }