/// <summary>
        /// Gets the new max key.
        /// </summary>
        /// <param name="transactionScopeConnection">The transaction scope connection.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <returns></returns>
        public override Int32 GetNewMaxKeyInt32(string tableName, string columnName, IDbConnection transactionScopeConnection)
        {
            // this will join in to any root transaction
            TransactionOptions serializableTransaction = new TransactionOptions();
            serializableTransaction.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
            using (DbTransactionScope scope = new DbTransactionScope(TransactionScopeOption.Required, serializableTransaction))
            {
                if (transactionScopeConnection == null)
                {
                    using (new DbConnectionScope())
                    {
                        Int32 newMaxKey = GetNewMaxKeyInt32(tableName, columnName, DbConnectionScope.Current.Connection);

                        scope.Complete();

                        return newMaxKey;
                    }
                }
                else
                {
                    using (IDataReader reader = ExecuteQueryReader(string.Format("select max({0})+1 from {1}", columnName, tableName), transactionScopeConnection))
                    {
                        Int32 ret = 1;
                        if (reader.Read() && !reader.IsDBNull(0))
                        {
                            ret = Database.Current.GetInt32(reader, 0);
                        }
                        scope.Complete();

                        return ret;
                    }
                }
            }
        }
        /// <summary>
        /// Ares the transactions nested.
        /// </summary>
        /// <returns></returns>
        public static bool AreTransactionsNested()
        {
            if (Log.Enabled) Log.Entry("AreTransactionsNested", s_scopes);

            bool result = false;

            if (s_scopes != null && s_scopes.Count > 1)
            {
                int uniqueTransactionScopes = 1;
                int l = s_scopes.Count;

                if (Log.Enabled) Log.LogDebug10("Transaction scope count = {0}", l);

                DbTransactionScope[] ar = new DbTransactionScope[l];
                s_scopes.CopyTo(ar, 0);
                DbTransactionScope x;
                int j;
                for (int i = 1; i < l; i++)
                {
                    x = ar[i];

                    for (j = 0; j < l; j++)
                    {
                        if (i != j && !x.Transaction.Equals(ar[j].Transaction))
                        {
                            break;
                        }
                    }

                    if (j < l)
                    {
                        uniqueTransactionScopes++;
                    }
                }

                if (Log.Enabled) Log.LogDebug10("Unique transaction scopes = {0}", uniqueTransactionScopes);

                result = uniqueTransactionScopes > 1;
            }

            if (Log.Enabled) Log.Exit("AreTransactionsNested", result);

            return result;
        }