コード例 #1
0
        protected override long InternalExecute()
        {
            var fields        = "*";
            var insertCommand = new RowInsertCommand(this.Connection, this.toTable);

            if (this.fieldDefinitions != null)
            {
                fields = this.fieldDefinitions.Select(definition => definition.Name).Join(",");
            }

            if (string.IsNullOrEmpty(fields))
            {
                return(0);
            }

            if (this.TableDefinition != null)
            {
                string sql = string.Format("SELECT {1} FROM {0}",
                                           this.TableDefinition.Name.AsDbName(),
                                           fields
                                           );

                // Log.DebugFormat(
                //  "Copy Table:From:'{0}',To:'{1}',Query:'{2}'",
                //  this.TableDefinition.Name.AsDbName(),
                //  this.toTable,
                //  sql
                //  );

                this.ExecuteQuery(
                    sql,
                    reader =>
                {
                    var row = TableRow.Read(this.TableDefinition, reader);

                    insertCommand.AddRowForInserting(row);

                    insertCommand.Execute(100);
                });
            }

            return(0L);
        }
コード例 #2
0
		protected override long InternalExecute()
		{
			var fields        = "*";
			var insertCommand = new RowInsertCommand(this.Connection, this.toTable);

			if (this.fieldDefinitions != null)
			{
				fields = this.fieldDefinitions.Select(definition => definition.Name).Join(",");
			}

			if (string.IsNullOrEmpty(fields))
			{
				return 0;
			}

			if (this.TableDefinition != null)
			{
				string sql = string.Format("SELECT {1} FROM {0}",
					this.TableDefinition.Name.AsDbName(),
					fields
				);

				// Log.DebugFormat(
				// 	"Copy Table:From:'{0}',To:'{1}',Query:'{2}'",
				// 	this.TableDefinition.Name.AsDbName(),
				// 	this.toTable,
				// 	sql
				// 	);

				this.ExecuteQuery(
					sql,
					reader =>
						{
							var row = TableRow.Read(this.TableDefinition, reader);

							insertCommand.AddRowForInserting(row);

							insertCommand.Execute(100);
						});
			}

			return 0L;
		}
コード例 #3
0
ファイル: Table.cs プロジェクト: saycale/MSSQLServerAuditor
		/// <summary>
		/// Add rows to table
		/// </summary>
		/// <param name="rows">Row collection</param>
		/// <returns></returns>
		public Int64? AddRows(IEnumerable<ITableRow> rows)
		{
			Int64?    lastRowIdentity = null;
			ITableRow lastTableRow    = null;

			using (this.Connection.OpenWrapper())
			{
				RowInsertCommand insertCommand = new RowInsertCommand(this.Connection, this.TableDefinition);

				foreach (ITableRow row in rows)
				{
					insertCommand.AddRowForInserting(row);

					lastTableRow = row;
				}

				insertCommand.Execute(100);

				if (lastTableRow != null)
				{
					lastRowIdentity = this.GetRow(lastTableRow);
				}

				return lastRowIdentity;
			}
		}