public IList <T> ObtenerListaObjetos <T>(string cmd, Func <Lector, T> mapeo, params Parametro[] parametros) where T : class { Inicializar(); using (var conn = CrearConnection()) { conn.Open(); using (var command = CrearCommand(conn, cmd, parametros)) using (var reader = command.ExecuteReader()) using (var lector = new Lector(reader)) { try { var res = new List <T>(); while (reader.Read()) { res.Add(mapeo(lector)); } return(res); } finally { reader.Close(); } } } }
public T Obtener <T>(string cmd, Func <Lector, T> mapeo, params Parametro[] parametros) { T resultado = default(T); EjecutarOperacion( cmd, parametros, (command) => { using (var reader = command.ExecuteReader()) using (var lector = new Lector(reader)) { try { if (reader.Read()) { resultado = mapeo(lector); } } finally { reader.Close(); } } }); return(resultado); }
public T ObtenerObjeto <T>(string cmd, Func <Lector, T> mapeo, params Parametro[] parametros) where T : class { Inicializar(); using (var conn = CrearConnection()) { conn.Open(); using (var command = CrearCommand(conn, cmd, parametros)) using (var reader = command.ExecuteReader()) using (var lector = new Lector(reader)) { try { if (reader.Read()) { return(mapeo(lector)); } return(default(T)); } finally { reader.Close(); } } } }
public IList <T> ObtenerLista <T>(string cmd, Func <Lector, T> mapeo, params Parametro[] parametros) { IList <T> resultado = new List <T>(); EjecutarOperacion( cmd, parametros, (command) => { using (var reader = command.ExecuteReader()) using (var lector = new Lector(reader)) { while (reader.Read()) { resultado.Add(mapeo(lector)); } } }); return(resultado); }