コード例 #1
0
        /// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommandBuilder.xml' path='docs/members[@name="SqlCommandBuilder"]/DeriveParameters/*'/>
        public static void DeriveParameters(SqlCommand command)
        {
            if (null == command)
            {
                throw ADP.ArgumentNull(nameof(command));
            }

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                command.DeriveParameters();
            }
            catch (OutOfMemoryException e)
            {
                command?.Connection?.Abort(e);
                throw;
            }
            catch (StackOverflowException e)
            {
                command?.Connection?.Abort(e);
                throw;
            }
            catch (ThreadAbortException e)
            {
                command?.Connection?.Abort(e);
                throw;
            }
        }
コード例 #2
0
ファイル: SqlCommandBuilder.cs プロジェクト: ph1294/SqlClient
        static public void DeriveParameters(SqlCommand command)
        { // MDAC 65927\
            SqlConnection.ExecutePermission.Demand();

            if (null == command)
            {
                throw ADP.ArgumentNull("command");
            }
            TdsParser bestEffortCleanupTarget = null;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
#if DEBUG
                TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();

                RuntimeHelpers.PrepareConstrainedRegions();
                try {
                    tdsReliabilitySection.Start();
#else
                {
#endif
                    bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(command.Connection);
                    command.DeriveParameters();
                }
#if DEBUG
                finally {
                    tdsReliabilitySection.Stop();
                }
#endif
            }
            catch (System.OutOfMemoryException e)
            {
                if (null != command && null != command.Connection)
                {
                    command.Connection.Abort(e);
                }
                throw;
            }
            catch (System.StackOverflowException e)
            {
                if (null != command && null != command.Connection)
                {
                    command.Connection.Abort(e);
                }
                throw;
            }
            catch (System.Threading.ThreadAbortException e)
            {
                if (null != command && null != command.Connection)
                {
                    command.Connection.Abort(e);
                }
                SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget);
                throw;
            }
        }
コード例 #3
0
        /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommandBuilder.xml' path='docs/members[@name="SqlCommandBuilder"]/DeriveParameters/*'/>
        public static void DeriveParameters(SqlCommand command)
        {
#if NETFRAMEWORK
            SqlConnection.ExecutePermission.Demand();
#endif
            if (null == command)
            {
                throw ADP.ArgumentNull(nameof(command));
            }
#if NETFRAMEWORK
            TdsParser bestEffortCleanupTarget = null;
#endif
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
#if NETFRAMEWORK
#if DEBUG
                TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();

                RuntimeHelpers.PrepareConstrainedRegions();
                try {
                    tdsReliabilitySection.Start();
#else
                {
#endif // DEBUG
                    bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(command.Connection);
#endif // NETFRAMEWORK
                command.DeriveParameters();
#if NETFRAMEWORK
            }
#if DEBUG
            finally {
                tdsReliabilitySection.Stop();
            }
#endif // DEBUG
#endif // NETFRAMEWORK
            }
            catch (OutOfMemoryException e)
            {
                command?.Connection?.Abort(e);
                throw;
            }
            catch (StackOverflowException e)
            {
                command?.Connection?.Abort(e);
                throw;
            }
            catch (ThreadAbortException e)
            {
                command?.Connection?.Abort(e);
#if NETFRAMEWORK
                SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget);
#endif
                throw;
            }
        }