コード例 #1
0
ファイル: TransactionState.cs プロジェクト: JasperFx/marten
 public TransactionState(IConnectionFactory factory, CommandRunnerMode mode, IsolationLevel isolationLevel, int commandTimeout)
 {
     _mode = mode;
     _isolationLevel = isolationLevel;
     this._commandTimeout = commandTimeout;
     Connection = factory.Create();
 }
コード例 #2
0
 public TransactionState(IConnectionFactory factory, CommandRunnerMode mode, IsolationLevel isolationLevel)
 {
     _mode = mode;
     _isolationLevel = isolationLevel;
     Connection = factory.Create();
     Connection.Open();
     BeginTransaction();
 }
コード例 #3
0
ファイル: TransactionState.cs プロジェクト: Xamarui/marten
 public TransactionState(IConnectionFactory factory, CommandRunnerMode mode, IsolationLevel isolationLevel)
 {
     _isolationLevel = isolationLevel;
     Connection = factory.Create();
     Connection.Open();
     if (mode == CommandRunnerMode.Transactional)
     {
         Transaction = Connection.BeginTransaction(isolationLevel);
     }
 }
コード例 #4
0
 public ManagedConnection(SessionOptions options, CommandRunnerMode mode) : this(options, mode, new NulloRetryPolicy())
 {
 }
コード例 #5
0
ファイル: DefaultTenancy.cs プロジェクト: rightteaminc/marten
 public IManagedConnection OpenConnection(CommandRunnerMode mode        = CommandRunnerMode.AutoCommit,
                                          IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, int?timeout = null)
 {
     return(_inner.OpenConnection(mode, isolationLevel, timeout));
 }
コード例 #6
0
ファイル: AdvancedOptions.cs プロジェクト: stush/marten
 /// <summary>
 ///     Directly open a managed connection to the underlying Postgresql database
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="isolationLevel"></param>
 /// <returns></returns>
 public IManagedConnection OpenConnection(CommandRunnerMode mode        = CommandRunnerMode.AutoCommit,
                                          IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
 {
     return(new ManagedConnection(Options.ConnectionFactory(), mode, isolationLevel));
 }
コード例 #7
0
ファイル: ManagedConnection.cs プロジェクト: mthird/marten
 public ManagedConnection(IConnectionFactory factory, CommandRunnerMode mode, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
 {
     _connection = new Lazy <TransactionState>(() => new TransactionState(factory, mode, isolationLevel));
 }
コード例 #8
0
 /// <summary>
 ///     Directly open a managed connection to the underlying Postgresql database
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="isolationLevel"></param>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public IManagedConnection OpenConnection(CommandRunnerMode mode = CommandRunnerMode.AutoCommit, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, int?timeout = null)
 {
     return(new ManagedConnection(_factory, mode, _options.RetryPolicy(), isolationLevel, timeout));
 }
コード例 #9
0
 /// <summary>
 /// Directly open a managed connection to the underlying Postgresql database
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="isolationLevel"></param>
 /// <returns></returns>
 public IManagedConnection OpenConnection(CommandRunnerMode mode = CommandRunnerMode.ReadOnly, IsolationLevel isolationLevel = IsolationLevel.ReadUncommitted)
 {
     return new ManagedConnection(Options.ConnectionFactory(), mode, isolationLevel);
 }
コード例 #10
0
 public ManagedConnection(IConnectionFactory factory, CommandRunnerMode mode,
                          IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, int commandTimeout = 30) : this(factory, mode,
                                                                                                                        new NulloRetryPolicy(), isolationLevel, commandTimeout)
 {
 }
コード例 #11
0
        internal async Task <IConnectionLifetime> InitializeAsync(DocumentStore store, CommandRunnerMode mode, CancellationToken token)
        {
            Mode = mode;
            Tenant ??= TenantId != null ? await store.Tenancy.GetTenantAsync(TenantId).ConfigureAwait(false) : store.Tenancy.Default;

            if (!store.Options.Advanced.DefaultTenantUsageEnabled &&
                Tenant.TenantId == Marten.Storage.Tenancy.DefaultTenantId)
            {
                throw new DefaultTenantUsageDisabledException();
            }

            if (!OwnsTransactionLifecycle && mode != CommandRunnerMode.ReadOnly)
            {
                Mode = CommandRunnerMode.External;
            }

            if (OwnsConnection && OwnsTransactionLifecycle)
            {
                var transaction = mode == CommandRunnerMode.ReadOnly
                    ? new ReadOnlyMartenControlledConnectionTransaction(this)
                    : new MartenControlledConnectionTransaction(this);

                await transaction.BeginTransactionAsync(token).ConfigureAwait(false);

                return(transaction);
            }

            if (Transaction != null)
            {
                return(new ExternalTransaction(this));
            }

            if (DotNetTransaction != null)
            {
                return(new AmbientTransactionLifetime(this));
            }

            throw new NotSupportedException("Invalid combination of SessionOptions");
        }
コード例 #12
0
ファイル: Tenant.cs プロジェクト: vgrokk/marten
 /// <summary>
 ///     Directly open a managed connection to the underlying Postgresql database
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="isolationLevel"></param>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public IManagedConnection OpenConnection(CommandRunnerMode mode = CommandRunnerMode.AutoCommit, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, int timeout = 30)
 {
     return(new ManagedConnection(_factory, mode, isolationLevel, timeout));
 }