Exemplo n.º 1
0
        /// <summary>DeleteChildrens a AccountBase record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">the version number of this row.</param>
        /// <param name="accountBaseId">The value for the AccountBaseId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void DeleteChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int accountBaseId)
        {
            // Accessor for the AccountBase Table.
            ServerMarketData.AccountBaseDataTable accountBaseTable = ServerMarketData.AccountBase;
            // This record can be used to iterate through all the children.
            ServerMarketData.AccountBaseRow accountBaseRow = accountBaseTable.FindByAccountBaseId(accountBaseId);
            // Delete the child records.
            for (int index = 0; (index < accountBaseRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerMarketData.AccountRow childAccountRow = accountBaseRow.GetAccountRows()[index];
                Account.DeleteChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < accountBaseRow.GetAccountGroupRows().Length); index = (index + 1))
            {
                ServerMarketData.AccountGroupRow childAccountGroupRow = accountBaseRow.GetAccountGroupRows()[index];
                AccountGroup.DeleteChildren(adoTransaction, sqlTransaction, childAccountGroupRow.RowVersion, childAccountGroupRow.AccountGroupId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            accountBaseRow[accountBaseTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(accountBaseRow);
            accountBaseRow.Delete();
            // Delete the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"AccountBase\" set \"IsDeleted\" = 1 where \"AccountBaseId\"=@accountBaseId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@accountBaseId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountBaseId));
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 2
0
 /// <summary>Collects the table lock request(s) for an Update operation</summary>
 /// <param name="adoTransaction">A list of locks required for this operation.</param>
 internal static void DeleteChildren(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Delete' operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.AccountBaseLock);
     Account.DeleteChildren(adoTransaction);
     AccountGroup.DeleteChildren(adoTransaction);
 }