public ICollection <T> ReadData <T>(IDataReader dataReader, IEntitySetting entity) { try { List <T> data = new List <T>(); while (dataReader.Read()) { data.Add(entity.EntitySetting <T>(dataReader)); } return(data); } catch { throw new Exception("Error to read data"); } }
public ICollection <T> Data <T>(IDbCommand command, IEntitySetting entity) { WriteInDiskLogfile writeLog = new WriteInDiskLogfile(); try { IDataReader reader = processData.ExecuteCommand(command); writeLog.Log("Successful data list return"); return(new List <T>(processData.ReadData <T>(reader, entity))); } catch (Exception ex) { WriteLog(writeLog, "Error while attempting to extract data list", 73, ex.GetType(), "Method <Data>"); throw new Exception(ex.Message); } }
public virtual ICollection <T> Data <T>(string sql, IEntitySetting entity, IDbConnection connection) { WriteInDiskLogfile writeLog = new WriteInDiskLogfile(); try { IDataReader reader = processData.ExecuteCommand(sql, connection); writeLog.Log("Successful data extraction process"); return(new List <T>(processData.ReadData <T>(reader, entity))); } catch (Exception ex) { WriteLog(writeLog, "Error in data extraction event", 12, ex.GetType(), "Method <Data>"); throw new Exception(ex.Message); } finally { connection.Close(); connection.Dispose(); } }