예제 #1
0
 public int Update(string table, string primarykey, string condition, object rowdata, IDbTransaction transaction)
 {
     if (primarykey == null)
     {
         throw new ArgumentNullException("primarykey");
     }
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     if (rowdata == null)
     {
         throw new ArgumentNullException("rowdata");
     }
     if (table.Length <= 0)
     {
         throw new ArgumentException("table");
     }
     if (primarykey.Length <= 0)
     {
         throw new ArgumentException("primarykey");
     }
     using (IDbCommand cmd = DatabaseAccessAuxiliary.CreateUpdate(rowdata, table, primarykey, condition, DatabaseAccessAdapter))
     {
         cmd.Transaction = transaction;
         return(ExecuteNonQuery(cmd));
     }
 }
예제 #2
0
        public IDbConnection Get(IRelational relational, Func <IDbConnection> newConnection)
        {
            if (relational == null)
            {
                throw new ArgumentNullException("relational");
            }
            if (newConnection == null)
            {
                throw new ArgumentNullException("newConnection");
            }
            else
            {
                this._newConnection = newConnection;
            }
            IDbConnection connection = null;

            if (!this._connections.TryGetValue(relational, out connection))
            {
                connection = newConnection();
                if (!DatabaseAccessAuxiliary.TryConnectConnection(connection))
                {
                    DatabaseAccessAuxiliary.CloseConnection(connection);
                    connection = null;
                }
                else
                {
                    relational.Disposed += this._closeRelationalEvt;
                    this._connections.Add(relational, connection);
                }
            }
            return(connection);
        }
예제 #3
0
        public IDbTransaction CreateTransaction()
        {
            IDbConnection connection = GetConnection();

            DatabaseAccessAuxiliary.ConnectConnection(connection);
            return(connection.BeginTransaction());
        }
예제 #4
0
 public DataTable Select(IDbCommand cmd)
 {
     if (cmd == null)
     {
         throw new ArgumentNullException("cmd");
     }
     return(DatabaseAccessAuxiliary.FillDataTable(cmd, DatabaseAccessAdapter));
 }
예제 #5
0
 public IDataReader ExecuteReader(IDbCommand cmd)
 {
     if (cmd == null)
     {
         throw new ArgumentNullException("cmd");
     }
     return(DatabaseAccessAuxiliary.ExecuteReader(cmd, DatabaseAccessAdapter));
 }
예제 #6
0
 public int ExecuteNonQuery(IDbCommand cmd)
 {
     if (cmd == null)
     {
         throw new ArgumentNullException("cmd");
     }
     return(DatabaseAccessAuxiliary.ExecuteNonQuery(cmd, DatabaseAccessAdapter));
 }
예제 #7
0
 public DataTable Select(string procedure, object parameter)
 {
     if (parameter == null)
     {
         throw new ArgumentNullException("parameter");
     }
     return(this.Select(procedure, DatabaseAccessAuxiliary.GetParameters(parameter, DatabaseAccessAdapter)));
 }
예제 #8
0
        public virtual IDbConnection Remove(IRelational relational)
        {
            if (relational == null)
            {
                throw new ArgumentNullException("relational");
            }
            IDbConnection connection = null;

            if (this._connections.TryGetValue(relational, out connection))
            {
                relational.Disposed -= this._closeRelationalEvt;
                this._connections.Remove(relational);
            }
            DatabaseAccessAuxiliary.CloseConnection(connection);
            return(connection);
        }
예제 #9
0
 public int Insert(string table, object rowdata, IDbTransaction transaction)
 {
     if (rowdata == null)
     {
         throw new ArgumentNullException("rowdata");
     }
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     if (table.Length <= 0)
     {
         throw new ArgumentException("table");
     }
     using (IDbCommand cmd = DatabaseAccessAuxiliary.CreateInsert(rowdata, table, DatabaseAccessAdapter))
     {
         cmd.Transaction = transaction;
         return(ExecuteNonQuery(cmd));
     }
 }
예제 #10
0
 public override IDbDataParameter[] GetParameters(string procedure)
 {
     return(DatabaseAccessAuxiliary.GetParameters <SqlConnection, SqlCommand>(procedure, this, (cmd) => SqlCommandBuilder.
                                                                              DeriveParameters(cmd)));
 }