示例#1
0
        /// <inheritdoc />
        public async Task RunInTransactionAsync(
            Action <ITransaction <TEntity> > action, CancellationToken cancellation = default(CancellationToken))
        {
            ITransactionalStoreContracts.RunInTransactionAsync(action);

            cancellation.ThrowIfCancellationRequested();
            await this.store.RunInTransactionAsync(
                transaction => action(new TypedTransaction <TEntity>(transaction)), cancellation).DontMarshallContext();
        }
        /// <inheritdoc />
        public async Task RunInTransactionAsync(
            Action <ITransaction <TEntity> > action, CancellationToken cancellation = default(CancellationToken))
        {
            ITransactionalStoreContracts.RunInTransactionAsync(action);

            cancellation.ThrowIfCancellationRequested();
            using (await this.Lock.WriterLockAsync(cancellation).DontMarshallContext())
            {
                cancellation.ThrowIfCancellationRequested();
                await this.store.RunInTransactionAsync(action, cancellation).DontMarshallContext();
            }
        }
        /// <inheritdoc />
        public Task RunInTransactionAsync(
            Action <ITransaction> action, CancellationToken cancellation = default(CancellationToken))
        {
            ITransactionalStoreContracts.RunInTransactionAsync(action);

            cancellation.ThrowIfCancellationRequested();
            return(this.connection.RunInTransactionAsync(
                       (SQLiteConnection conn) =>
            {
                using (var transaction = new Transaction(conn))
                {
                    action(transaction);
                }
            },
                       cancellation));
        }