Beispiel #1
0
        public Collection <T> MapAll(DataSet ds, UInt64 uRecordsToRead)
        {
            Collection <T> collection = new Collection <T>();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                try
                {
                    collection.Add(Map(row, uRecordsToRead));
                }
                catch (Exception ex)
                {
                    //throw;
                    // Consider handling exception (instead of re-throwing) if graceful recovery is possible
                    Console.WriteLine(UtilitiesGeneral.FormatException(
                                          this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message));
                }
            }

            return(collection);
        }
Beispiel #2
0
        // Execute method
        public DataSet Execute()
        {
            DataSet ds = new DataSet();

            using (IDbConnection connection = GetConnection())
            {
                IDbCommand command = connection.CreateCommand();
                command.Connection  = connection;
                command.CommandText = CmdText;
                command.CommandType = CmdType;
                foreach (IDataParameter param in GetParameters(command))
                {
                    command.Parameters.Add(param);
                }

                IDbDataAdapter adapter = GetAdapter();
                adapter.SelectCommand = command;
                try
                {
                    connection.Open();
                    adapter.Fill(ds);
                }
                catch (Exception ex)
                {
                    // throw?
                    Console.WriteLine(UtilitiesGeneral.FormatException(
                                          this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message));
                }
                finally
                {
                    connection.Close();
                }
            }

            return(ds);
        }