public static DataAccessLayer.DBCommand Add(this DataAccessLayer.DBCommand sql,
                                             DataAccessLayer.DBCommand dbCommand, string paramName, string outputParamName,
                                             System.Data.ParameterDirection direction = System.Data.ParameterDirection.Input)
 {
     sql.AddParameter(dbCommand, paramName, outputParamName, direction);
     return(sql);
 }
Beispiel #2
0
        /// <summary>
        /// use this method to use the output of another DBCommand for the input of the current DBCommand parameter
        /// </summary>
        /// <param name="dbCommand">DBCommand instance that you will get the output value from</param>
        /// <param name="paramName">name of the input parameter for the current DBCommand instance</param>
        /// <param name="outputParamName">name of the output parameter of another DBCommand instance you want to use as your input value</param>
        /// <param name="direction">direction of your input parameter for the current DBCommand instance</param>
        public void AddParameter(DBCommand dbCommand, string paramName, string outputParamName, ParameterDirection direction = ParameterDirection.Input, DbType type = DbType.Object)
        {
            ParameterExtendedData param = new ParameterExtendedData();

            param.objectID                 = dbCommand.id;
            param.objectParameterName      = outputParamName;
            param.destinationParameterName = paramName;
            param.direction                = direction;
            param.type = type;

            extendedData.Add(param);
        }
Beispiel #3
0
        public int BatchExecute(params DBCommand[] dbCommands)
        {
            batchException.Clear();
            int processsed = 0;

            this.providerType = dbCommands[0].ProviderType;
            if (dbCommands[0].connectionString.Trim() != "")
            {
                this.strConnection = dbCommands[0].connectionString;
            }

            Open(); // start DB connection

            if (enableBatchTransaction)
            {
                BeginTransaction();
            }

            for (int i = 0; i < dbCommands.Length; i++)
            {
                ClearParameters();

                try
                {
                    DBCommand d = dbCommands[i];
                    // first get all the independent parameters
                    foreach (IDbDataParameter p in d.IDBParameters)
                    {
                        AddParameters(p.ParameterName, p.Direction, p.DbType, p.Value);
                    }

                    // now get all the dependent parameters
                    if (i > 0)
                    {
                        foreach (ParameterExtendedData p in d.ExtendedData)
                        {
                            AddParameters(p.destinationParameterName, p.direction, GetOutputParameterType(p.objectParameterName), GetOutputParameterValue(p.objectParameterName));
                        }
                    }

                    ExecuteNonQuery(d.commandType, d.commandText);

                    processsed += 1;
                }
                catch (Exception ex)
                {
                    batchException.Add(ex);
                    if (enableBatchTransaction)
                    {
                        RollBackTransaction();
                        Close();

                        return(processsed);
                    }
                }
            }

            if (enableBatchTransaction)
            {
                CommitTransaction();
            }

            Close();    // close DB connection

            return(processsed);
        }
 public static DataAccessLayer.DBCommand Add(this DataAccessLayer.DBCommand sql, string paramName,
                                             System.Data.ParameterDirection direction, System.Data.DbType type, object objValue = null)
 {
     sql.AddParameter(paramName, direction, type, objValue);
     return(sql);
 }
 public static DataAccessLayer.DBCommand Update(this DataAccessLayer.DBCommand sql, string paramName, object objValue)
 {
     sql.UpdateParameter(paramName, objValue);
     return(sql);
 }