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


C# TransactionManager.Commit方法代码示例

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


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

示例1: Instead01

 private void Instead01(TransactionManager tm, Customer cus)
 {
     MessageBox.Show("Something...");
     // Begin the transaction after the message box,
     // e.g. if you want to prompt them to do something before saving.
     tm.BeginTransaction();
     DataRepository.CustomerProvider.Insert(tm, cus);
     tm.Commit();
 }
开发者ID:ITAfrique,项目名称:CodingStandards,代码行数:9,代码来源:C06_TransactionMisuse.cs

示例2: Instead02

 private void Instead02(TransactionManager tm, Customer cus)
 {
     tm.BeginTransaction();
     DataRepository.CustomerProvider.Insert(tm, cus);
     tm.Commit();
     // Or, show the message box after the transaction completed,
     // e.g. to notify them of an event after saving
     MessageBox.Show("Something...");
 }
开发者ID:ITAfrique,项目名称:CodingStandards,代码行数:9,代码来源:C06_TransactionMisuse.cs

示例3: ApplyRecord

      /// <summary>
      /// Apply a record to placeholders
      /// </summary>
		/// <param name="placeHolders">List of placeholder which should be applied</param>
		/// <param name="recordName">Name of record</param>
		/// <returns>Return true if one or more was applied</returns>
      public static void ApplyRecord(IEnumerable<PlaceHolder> placeHolders, string recordName)
      {
         using (Transaction transaction = new TransactionManager().CreateTransaction())
         {
            foreach (PlaceHolder placeHolder in placeHolders)
            {
               placeHolder.ApplyRecord(recordName, true); // apply (with page data)
               transaction.Commit(); // needed if not placed in project
            }
         }
      }
开发者ID:Suplanus,项目名称:Suplanus.Sepla,代码行数:17,代码来源:PlaceHolderUtility.cs

示例4: BadlyMisplacedCode

        // SAMPLE 01
        //
        // As mentioned in "C01_TransactionManager," the idea behind transactions
        // is that it should surround a block of code that either saves everything
        // or nothing.
        //
        // Here is the thing to remember: While the transaction is open it will prevent
        // anything from accessing the database tables that you are busy with. This is
        // to prevent "dirty" or incomplete records.
        //
        // The caveat: you want your transaction to execute as fast as possible. Be
        // like a ninja: get in, do your thing, and get out.
        //
        private void BadlyMisplacedCode(TransactionManager tm, Customer cus)
        {
            tm.BeginTransaction();
            DataRepository.CustomerProvider.Insert(tm, cus);
            MessageBox.Show("Something...");
            tm.Commit();

            // Can you see it?
            // This code will block the Customer table on the entire branch until the user
            // clicks "OK" on the message box. The impact of this is enourmous.
        }
开发者ID:ITAfrique,项目名称:CodingStandards,代码行数:24,代码来源:C06_TransactionMisuse.cs

示例5: CreateRecordWithValueAndApply

      /// <summary>
      /// Create a record to a placeHolder by name and apply a record
      /// </summary>
		/// <param name="placeHolders">List of placeholder which should be applied</param>
		/// <param name="placeHolderName">Name of placeholder</param>
		/// <param name="recordName">Name of record</param>
      /// <param name="variableName">Variable to set</param>
      /// <param name="value">New value of the variable</param>
		/// <returns>Return true if one or more was applied</returns>
      public bool CreateRecordWithValueAndApply(PlaceHolder[] placeHolders, string placeHolderName, string recordName, string variableName, string value)
		{
			List<PlaceHolder> foundPlaceHolder = placeHolders
				.Where(placeHolder => placeHolder.Name.Equals(placeHolderName)) // name
				.ToList();

			foreach (PlaceHolder placeHolder in foundPlaceHolder)
			{
				placeHolder.AddRecord(recordName);
				placeHolder.set_Value(recordName, variableName, value);
				using (Transaction transaction = new TransactionManager().CreateTransaction())
				{
					placeHolder.ApplyRecord(recordName, true); // apply (with page data)
					transaction.Commit(); // needed if not placed in project
				}
			}

			return foundPlaceHolder.Any(); // true == found | false == not found
		}
开发者ID:Suplanus,项目名称:Suplanus.Sepla,代码行数:28,代码来源:PlaceHolderUtility.cs


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