public List <Estructura> Listar(EstructuraFiltro filtro = null) { using (_contexto = new ALICORPContexto()) { try { _repositorio = new EstructuraRepositorio(_contexto.Connection); return(_repositorio.Listar(filtro)); } catch (Exception ex) { throw ex; } } }
public List <Estructura> Listar(EstructuraFiltro filtro) { List <Estructura> lista = new List <Estructura>(); try { using (var cmd = CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Estructura_Listar"; cmd.Parameters.AddWithValue("@tablero", filtro?.Tablero ?? Convert.DBNull); using (var rd = cmd.ExecuteReader()) { while (rd.Read()) { lista.Add(new Estructura { Id = rd.GetInt32(0), PadreId = !rd.IsDBNull(1) ? rd.GetInt32(1) : (int?)null, Codigo = !rd.IsDBNull(2) ? rd.GetString(2) : null, Descripcion = rd.GetString(3), Tablero = rd.GetBoolean(4) }); } rd.Close(); } } return(lista); } catch (Exception) { throw new Exception("Ocurrió un problema al listar las estructuras."); } }