예제 #1
0
 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");
     }
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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();
            }
        }