当前位置: 首页>>代码示例>>C#>>正文


C# IDbTransaction.Dispose方法代码示例

本文整理汇总了C#中IDbTransaction.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IDbTransaction.Dispose方法的具体用法?C# IDbTransaction.Dispose怎么用?C# IDbTransaction.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDbTransaction的用法示例。


在下文中一共展示了IDbTransaction.Dispose方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateQueuedAndHistoryForSchedule

        /// <summary>
        /// Creates the queue and history records for the given schedule.
        /// </summary>
        /// <param name="scheduleId">The ID of the schedule records are being created for.</param>
        /// <param name="scheduleDate">The schedule date records are being created for.</param>
        /// <param name="queued">The queued records to create.</param>
        /// <param name="history">The history records to create.</param>
        /// <param name="transaction">The transaction to use, if applicable.</param>
        /// <returns>The number of records created.</returns>
        public int CreateQueuedAndHistoryForSchedule(long scheduleId, DateTime scheduleDate, IEnumerable<QueueRecord> queued, IEnumerable<HistoryRecord> history, IDbTransaction transaction)
        {
            int created = 0;
            bool commitRollback = false;

            if (transaction == null)
            {
                commitRollback = true;
                transaction = this.BeginTransaction();
            }

            try
            {
                const string InsertQueuedSql =
            @"INSERT INTO [BlueCollarQueue]([ApplicationName],[ScheduleId],[QueueName],[JobName],[JobType],[Data],[QueuedOn],[TryNumber])
            VALUES(@ApplicationName,@ScheduleId,@QueueName,@JobName,@JobType,@Data,@QueuedOn,@TryNumber);";

                const string InsertHistorySql =
            @"INSERT INTO [BlueCollarHistory]([ApplicationName],[WorkerId],[ScheduleId],[QueueName],[JobName],[JobType],[Data],[QueuedOn],[TryNumber],[StartedOn],[Status],[Exception],[FinishedOn])
            VALUES (@ApplicationName,@WorkerId,@ScheduleId,@QueueName,@JobName,@JobType,@Data,@QueuedOn,@TryNumber,@StartedOn,@StatusString,@Exception,@FinishedOn);";

                if (queued != null && queued.Count() > 0)
                {
                    created += this.connection.Execute(InsertQueuedSql, queued, transaction, null, null);
                }

                if (history != null && history.Count() > 0)
                {
                    created += this.connection.Execute(InsertHistorySql, history, transaction, null, null);
                }

                if (commitRollback)
                {
                    transaction.Commit();
                }
            }
            catch
            {
                if (commitRollback)
                {
                    transaction.Rollback();
                }

                throw;
            }
            finally
            {
                if (commitRollback)
                {
                    transaction.Dispose();
                }
            }

            return created;
        }
开发者ID:ChadBurggraf,项目名称:blue-collar,代码行数:64,代码来源:SqlServerRepository.cs

示例2: DisposeTransaction

 /// <summary>
 /// 子类实现此方法释放指定的事务。
 /// </summary>
 /// <returns></returns>
 protected virtual void DisposeTransaction(IDbTransaction tran)
 {
     tran.Dispose();
 }
开发者ID:jack-tmac,项目名称:LCLFramework,代码行数:8,代码来源:LocalTransactionBlock_1_0.cs

示例3:

 /// <summary>
 /// Закрыть транзакцию
 /// </summary>
 /// <param name="transaction"></param>
 public static void СommitTransaction(IDbTransaction transaction) {
   if (transaction != null) {
     var v_storedConn = transaction.Connection;
     transaction.Commit();
     transaction.Dispose();
     if (v_storedConn != null) {
       v_storedConn.Close();
       v_storedConn.Dispose();
     }
   }
 }
开发者ID:tormoz70,项目名称:Bio.Framework.8,代码行数:15,代码来源:DBSession.cs

示例4: RollbackTransaction

 /// <summary>
 /// Откатить транзакцию
 /// </summary>
 /// <param name="trans"></param>
 public static void RollbackTransaction(IDbTransaction trans) {
   if (trans != null) {
     var v_storedConn = trans.Connection;
     try {
       trans.Rollback();
     } catch (InvalidOperationException) { }
     trans.Dispose();
     if (v_storedConn != null) {
       v_storedConn.Close();
       v_storedConn.Dispose();
     }
   }
 }
开发者ID:tormoz70,项目名称:Bio.Framework.8,代码行数:17,代码来源:DBSession.cs

示例5: Execute

	    /// <summary>
	    /// The execute.
	    /// </summary>
	    /// <param name="dbfunctionType">
	    /// The dbfunction type.
	    /// </param>
	    /// <param name="operationName">
	    /// The operation name.
	    /// </param>
	    /// <param name="parameters">
	    /// The parameters.
	    /// </param>
	    /// <param name="result">
	    /// The result.
	    /// </param>
	    /// <param name="transaction"></param>
	    /// <returns>
	    /// The execute.
	    /// </returns>
	    public virtual bool Execute(
			DbFunctionType dbfunctionType, 
			[NotNull] string operationName, 
			[NotNull] IEnumerable<KeyValuePair<string, object>> parameters, 
			[CanBeNull] out object result,
            IDbTransaction transaction = null)
		{
			if (this.IsSupportedOperation(operationName))
			{
				this._sqlMessages.Clear();

			    bool createdTransaction = transaction == null;

			    try
			    {
                    if (transaction == null)
                    {
                        transaction = this.DbAccess.BeginTransaction();
                    }

                    if (transaction.Connection is SqlConnection)
                    {
                        var sqlConnection = transaction.Connection as SqlConnection;
                        sqlConnection.FireInfoMessageEventOnUserErrors = true;
                        sqlConnection.InfoMessage += new SqlInfoMessageEventHandler(this.sqlConnection_InfoMessage);

                        var operationSuccessful = this.RunOperation(sqlConnection, transaction, dbfunctionType, operationName, parameters, out result);

                        if (createdTransaction && operationSuccessful)
                        {
                            transaction.Commit();
                        }

                        return operationSuccessful;
                    }
			    }
			    finally
			    {
                    if (createdTransaction && transaction != null)
			        {
                        transaction.Dispose();
			        }
			    }
			}

			result = null;

			return false;
		}
开发者ID:bugjohnyang,项目名称:YAFNET,代码行数:68,代码来源:BaseMsSqlFunction.cs

示例6: BeginTransaction

        public void BeginTransaction(IsolationLevel isolationLevel)
        {
            if (IsOpen) {
                throw new InvalidOperationException("Transaction already open.");
            }

            //Open connection
            try {
                connection.Open();
                transaction = this.connection.BeginTransaction(isolationLevel);
                transactionOpen = true;
            } catch (Exception) {
                // in the event of an error, close the connection and destroy the transaction object.
                if (connection != null) {
                    connection.Close();
                }

                if (transaction != null) {
                    transaction.Dispose();
                }

                transactionOpen = false;
                throw;
            }
        }
开发者ID:jdaigle,项目名称:DataTiers,代码行数:25,代码来源:TransactionManager.cs

示例7: CloseConnection

 public void CloseConnection(IDbTransaction tran)
 {
     if (tran.Connection != null && tran.Connection.State != ConnectionState.Closed)
     {
         try
         {
             tran.Connection.Close();
             tran.Connection.Dispose();
         }
         finally
         {
             tran.Dispose();
         }
     }
 }
开发者ID:dalinhuang,项目名称:myxx,代码行数:15,代码来源:DataBase.cs

示例8: EndUpdate

 public void EndUpdate(IDbTransaction trans)
 {
     trans.Commit();
     trans.Dispose();
     m_conn.Close();
     m_conn = null;
 }
开发者ID:TweetyHH,项目名称:Open-Cache-Manager,代码行数:7,代码来源:CacheStore.cs

示例9: CancelUpdate

 public void CancelUpdate(IDbTransaction trans)
 {
     trans.Rollback();
     trans.Dispose();
     m_conn.Close();
     m_conn = null;
 }
开发者ID:TweetyHH,项目名称:Open-Cache-Manager,代码行数:7,代码来源:CacheStore.cs


注:本文中的IDbTransaction.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。