예제 #1
0
        /// <summary>
        /// 执行sql语句,不返回任何结果集。
        /// </summary>
        /// <param name="db">企业库扩展:<typeparamref name="Database"/></param>
        /// <param name="batch">sql批次</param>
        /// <param name="transaction">事务处理</param>
        /// <returns>受影响的行数</returns>
        public static int ExecuteSqlNonQuery(this Database db, BatchSQL batch, DbTransaction transaction)
        {
            StringBuilder sql = new StringBuilder();

            foreach (string sqlStatment in batch)
            {
                sql.AppendLine(sqlStatment);
            }

            DbCommand command = db.BuilderDbCommand(CommandType.Text, sql.ToString(), batch.Parameters);

            return(db.ExecuteNonQuery(command, transaction));
        }
예제 #2
0
        /// <summary>
        /// 执行sql语句,返回DataSet(批量执行,没有事物支持不能保证数据的一致性和完整性)。
        /// </summary>
        /// <param name="db">企业库扩展:<typeparamref name="Database"/></param>
        /// <param name="batch">sql批次</param>
        /// <returns>返回一个DataSet</returns>
        public static DataSet ExecuteSqlDataSet(this Database db, BatchSQL batch)
        {
            StringBuilder sql = new StringBuilder();

            foreach (string sqlStatment in batch)
            {
                sql.AppendLine(sqlStatment);
            }

            DbCommand command = db.BuilderDbCommand(CommandType.Text, sql.ToString(), batch.Parameters);

            return(db.ExecuteDataSet(command));
        }