本文整理汇总了C#中System.Transactions.CommittableTransaction.EnlistVolatile方法的典型用法代码示例。如果您正苦于以下问题:C# CommittableTransaction.EnlistVolatile方法的具体用法?C# CommittableTransaction.EnlistVolatile怎么用?C# CommittableTransaction.EnlistVolatile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Transactions.CommittableTransaction
的用法示例。
在下文中一共展示了CommittableTransaction.EnlistVolatile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetryOnFailure
public void RetryOnFailure()
{
using (var t = new CommittableTransaction())
using (new TxScope(t, NullLogger.Instance))
{
t.EnlistVolatile(new ThrowingResource(true), EnlistmentOptions.EnlistDuringPrepareRequired);
using (var c = GetConnection())
using (var cmd = c.CreateCommand())
{
cmd.CommandText = "SELECT TOP 1 Val FROM Thing";
var scalar = (double)cmd.ExecuteScalar();
Console.WriteLine("got val {0}", scalar);
}
try
{
t.Commit();
Assert.Fail("first commit should fail");
}
catch (ApplicationException)
{
Assert.That(t.TransactionInformation.Status, Is.EqualTo(TransactionStatus.Committed));
}
}
}