Example #1
0
        //-- lista

        public IList GetLista(Type type, object filtro = null, bool relacao = false, int qtde = -1, int pagina = 0)
        {
            var lista = TypeForConvert.GetObjectFor(typeof(List <>), type) as IList;

            _ambiente.SetarFiltroPadrao(filtro);

            var where = filtro is string?filtro as string : null;

            var sql = _comando
                      .ComTipoObjeto(type)
                      .ComWhere(where)
                      .ComQtde(qtde)
                      .ComPagina(pagina)
                      .GetSelect();

            _conexao
            .Connection
            .Query(sql: sql, type: type)
            .ToList()
            .ForEach(dataReader =>
            {
                var obj = Activator.CreateInstance(type);
                lista.Add(obj);
                obj.SetValueFromObjeto(dataReader);
                if (relacao)
                {
                    this.GetRelacaoLista(obj, false, _ambiente.TipoDatabase);
                }
            });

            return(lista);
        }