本文整理汇总了C#中TransactionScopeOption类的典型用法代码示例。如果您正苦于以下问题:C# TransactionScopeOption类的具体用法?C# TransactionScopeOption怎么用?C# TransactionScopeOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionScopeOption类属于命名空间,在下文中一共展示了TransactionScopeOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SafeTransaction
public SafeTransaction(TransactionScopeOption scopeOption = TransactionScopeOption.RequiresNew)
{
if (Database.DefaultConnectionFactory is SqlCeConnectionFactory)
_transaction = null;
else
_transaction = new TransactionScope(scopeOption);
}
示例2: TransactionalOperationAttribute
public TransactionalOperationAttribute(TransactionScopeOption option)
: base(false)
{
this.Option = option;
this.IsolationLevel = DefaultIsolationLevel;
this.TimeoutMs = DefaultTimeoutMs;
}
示例3: TransactionScope
public TransactionScope(
TransactionScopeOption scopeOption,
TransactionScopeAsyncFlowOption asyncFlowOption
)
{
if ( !TransactionManager._platformValidated ) TransactionManager.ValidatePlatform();
if ( DiagnosticTrace.Verbose )
{
MethodEnteredTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
"TransactionScope.ctor( TransactionScopeOption )"
);
}
ValidateAndSetAsyncFlowOption(asyncFlowOption);
if ( NeedToCreateTransaction( scopeOption ) )
{
committableTransaction = new CommittableTransaction();
expectedCurrent = committableTransaction.Clone();
}
if ( DiagnosticTrace.Information )
{
if ( null == expectedCurrent )
{
TransactionScopeCreatedTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
TransactionTraceIdentifier.Empty,
TransactionScopeResult.NoTransaction
);
}
else
{
TransactionScopeResult scopeResult;
if ( null == committableTransaction )
{
scopeResult = TransactionScopeResult.UsingExistingCurrent;
}
else
{
scopeResult = TransactionScopeResult.CreatedTransaction;
}
TransactionScopeCreatedTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
expectedCurrent.TransactionTraceId,
scopeResult
);
}
}
PushScope();
if ( DiagnosticTrace.Verbose )
{
MethodExitedTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
"TransactionScope.ctor( TransactionScopeOption )"
);
}
}
示例4: TransactionAttribute
public TransactionAttribute(TransactionScopeOption mode, IsolationLevel isolationLevel)
{
Timeout = TimeSpan.MaxValue;
Mode = mode;
IsolationLevel = isolationLevel;
_CustomContext = new Dictionary<string, object>();
}
示例5: Commit
public void Commit(TransactionScopeOption scopeOption, TransactionOptions transactionOptions)
{
using (TransactionScope scope = new TransactionScope(scopeOption, transactionOptions))
{
foreach (UnitOfWork.Operation operation2 in from o in this.operations
orderby o.ProcessDate
select o)
{
switch (operation2.Type)
{
case UnitOfWork.OperationType.Insert:
operation2.Repository.PersistNewItem(operation2.Entity);
break;
case UnitOfWork.OperationType.Update:
operation2.Repository.PersistUpdatedItem(operation2.Entity);
break;
case UnitOfWork.OperationType.Delete:
operation2.Repository.PersistDeletedItem(operation2.Entity);
break;
}
}
scope.Complete();
}
foreach (EntityBase entityBase in (from operation in this.operations
select operation.Entity).OfType<EntityBase>())
{
entityBase.ClearChangedProperties();
}
this.Reset();
}
示例6: InheritedSqlPersistenceEngine
public InheritedSqlPersistenceEngine(
IConnectionFactory connectionFactory,
ISqlDialect dialect,
ISerialize serializer,
TransactionScopeOption scopeOption, int pageSize)
: base(connectionFactory, dialect, serializer, scopeOption, pageSize)
{}
示例7: Init
private void Init(TransactionScopeOption option, IsolationLevel isolationLevel)
{
_scope = new TransactionScope(option, new TransactionOptions()
{
IsolationLevel = isolationLevel
});
}
示例8: SqlPersistenceFactory
private SqlPersistenceFactory(ISerialize serializer, TransactionScopeOption scopeOption, IStreamIdHasher streamIdHasher, int pageSize)
{
_serializer = serializer;
_scopeOption = scopeOption;
_streamIdHasher = streamIdHasher ?? new Sha1StreamIdHasher();
PageSize = pageSize;
}
示例9: CreateRepeatableRead
//TransactionScopeAsyncFlowOption transactionScopeAsyncFlowOption = TransactionScopeAsyncFlowOption.Suppress) // .NET 4.5.1 feature
public static TransactionScope CreateRepeatableRead(
TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required,
TimeSpan? timeout = null)
{
var transactionOptions = new TransactionOptions
{
IsolationLevel = IsolationLevel.RepeatableRead,
};
// Upgrade isolation level if necessary
if (transactionScopeOption == TransactionScopeOption.Required)
{
var currentTransaction = Transaction.Current;
if (currentTransaction != null && currentTransaction.IsolationLevel == IsolationLevel.Serializable)
{
transactionOptions.IsolationLevel = currentTransaction.IsolationLevel;
}
}
if (timeout.HasValue)
{
transactionOptions.Timeout = timeout.Value;
}
return new TransactionScope(transactionScopeOption, transactionOptions/*, transactionScopeAsyncFlowOption*/);
}
示例10: FatQueueTransaction
public FatQueueTransaction(
IsolationLevel isolationLevel,
TimeSpan? timeout,
Func<IDbConnection> connectionFactory,
TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required,
TransactionScopeAsyncFlowOption transactionScopeAsyncFlowOption = TransactionScopeAsyncFlowOption.Enabled)
{
_connectionFactory = connectionFactory;
var transactionOptions = new TransactionOptions
{
IsolationLevel = isolationLevel,
};
if (timeout != null)
{
transactionOptions.Timeout = timeout.Value;
}
if (System.Transactions.Transaction.Current == null || transactionScopeOption == TransactionScopeOption.RequiresNew)
{
_transaction = new CommittableTransaction(transactionOptions);
_transactionScope = new TransactionScope(_transaction, transactionScopeAsyncFlowOption);
}
}
示例11: StartTransaction
public static TransactionScope StartTransaction(this IMessageContext messageContext,
TransactionScopeOption option = TransactionScopeOption.Required)
{
var scope = new TransactionScope(option);
messageContext.EnlistInCurrentTransaction();
return scope;
}
示例12: SqlPersistenceFactory
private SqlPersistenceFactory(ISerialize serializer, TransactionScopeOption scopeOption, int pageSize)
{
this.serializer = serializer;
this.scopeOption = scopeOption;
this.PageSize = pageSize;
}
示例13: TransactionScope
public TransactionScope (TransactionScopeOption scopeOption,
TransactionOptions options,
DTCOption opt)
{
Initialize (scopeOption, null, options, opt,
TransactionManager.DefaultTimeout);
}
示例14: CreateTransactionScopeWithNoLock
public static TransactionScope CreateTransactionScopeWithNoLock(TransactionScopeOption option)
{
TransactionOptions options = new TransactionOptions();
options.IsolationLevel = IsolationLevel.ReadUncommitted;
return new TransactionScope(option, options);
}
示例15: Acquire
public static TransactionScope Acquire(TransactionScopeOption scope,
IsolationLevel isolationLevel, TimeSpan timeout,
TransactionScopeAsyncFlowOption asyncFlowOption)
{
TransactionOptions options = new TransactionOptions {IsolationLevel = isolationLevel, Timeout = timeout};
TransactionScope result = new TransactionScope(scope, options, asyncFlowOption);
return result;
}