Esempio n. 1
0
        /// <inheritdoc />
        public async Task UpdateAsync(TEntity entity, CancellationToken cancellation = default(CancellationToken))
        {
            IAsyncStoreContracts.UpdateAsync(entity);

            cancellation.ThrowIfCancellationRequested();
            await this.store.UpdateAsync(entity, cancellation).DontMarshallContext();
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task AddOrUpdateAllAsync(
            IEnumerable <TEntity> entities, CancellationToken cancellation = default(CancellationToken))
        {
            IAsyncStoreContracts.AddOrUpdateAllAsync(entities);

            cancellation.ThrowIfCancellationRequested();
            await this.store.AddOrUpdateAllAsync(entities, cancellation).DontMarshallContext();
        }
Esempio n. 3
0
        /// <inheritdoc />
        public async Task <IEnumerable <TEntity> > WhereAsync(
            Expression <Func <TEntity, bool> > predicate, CancellationToken cancellation = default(CancellationToken))
        {
            IAsyncStoreContracts.WhereAsync(predicate);

            cancellation.ThrowIfCancellationRequested();
            return(await this.store.WhereAsync(predicate, cancellation).DontMarshallContext());
        }
        /// <inheritdoc />
        public Task AddOrIgnoreAllAsync <TEntity>(
            IEnumerable <TEntity> entities, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.AddOrIgnoreAllAsync(entities);

            cancellation.ThrowIfCancellationRequested();
            return(this.connection.InsertOrIgnoreAllAsync(entities, cancellation));
        }
        /// <inheritdoc />
        public Task AddAsync <TEntity>(
            TEntity entity, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.AddAsync(entity);

            cancellation.ThrowIfCancellationRequested();
            return(this.connection.InsertAsync(entity, cancellation));
        }
        /// <inheritdoc />
        public Task RemoveAllAsync <TEntity>(
            IEnumerable <TEntity> entities, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.RemoveAllAsync(entities);

            cancellation.ThrowIfCancellationRequested();
            return(this.RunInTransactionAsync(transaction => transaction.RemoveAll(entities), cancellation));
        }
Esempio n. 7
0
        /// <inheritdoc />
        public async Task AddOrUpdateAsync <TEntity>(
            TEntity entity, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.AddOrUpdateAsync(entity);

            var store = await this.GetStoreAsync <TEntity>(cancellation).DontMarshallContext();

            await store.AddOrUpdateAsync(entity, cancellation).DontMarshallContext();
        }
Esempio n. 8
0
        /// <inheritdoc />
        public async Task AddOrIgnoreAllAsync <TEntity>(
            IEnumerable <TEntity> entities, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.AddOrIgnoreAllAsync(entities);

            var store = await this.GetStoreAsync <TEntity>(cancellation).DontMarshallContext();

            await store.AddOrIgnoreAllAsync(entities, cancellation).DontMarshallContext();
        }
Esempio n. 9
0
        /// <inheritdoc />
        public async Task <IEnumerable <TEntity> > WhereAsync <TEntity>(
            Expression <Func <TEntity, bool> > predicate, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.WhereAsync(predicate);

            var store = await this.GetStoreAsync <TEntity>(cancellation).DontMarshallContext();

            return(await store.WhereAsync(predicate, cancellation).DontMarshallContext());
        }
        /// <inheritdoc />
        public Task AddOrIgnoreAsync <TEntity>(
            TEntity entity, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.AddOrIgnoreAsync(entity);

            // for some reason there is no overload that accepts a CancellationToken
            cancellation.ThrowIfCancellationRequested();
            return(this.connection.InsertOrIgnoreAsync(entity));
        }
Esempio n. 11
0
        /// <inheritdoc />
        public async Task AddOrIgnoreAsync(TEntity entity, CancellationToken cancellation = default(CancellationToken))
        {
            IAsyncStoreContracts.AddOrIgnoreAsync(entity);

            cancellation.ThrowIfCancellationRequested();
            using (await this.Lock.WriterLockAsync(cancellation).DontMarshallContext())
            {
                cancellation.ThrowIfCancellationRequested();
                await this.store.AddOrIgnoreAsync(entity, cancellation).DontMarshallContext();
            }
        }
        /// <inheritdoc />
        public async Task <IEnumerable <TEntity> > WhereAsync <TEntity>(
            Expression <Func <TEntity, bool> > predicate, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.WhereAsync(predicate);

            cancellation.ThrowIfCancellationRequested();
            return(await this.connection.Table <TEntity>()
                   .Where(predicate)
                   .ToListAsync(cancellation)
                   .DontMarshallContext());
        }
Esempio n. 13
0
        /// <inheritdoc />
        public async Task RemoveAllAsync(
            IEnumerable <TEntity> entities, CancellationToken cancellation = default(CancellationToken))
        {
            IAsyncStoreContracts.RemoveAllAsync(entities);

            cancellation.ThrowIfCancellationRequested();
            using (await this.Lock.WriterLockAsync(cancellation).DontMarshallContext())
            {
                cancellation.ThrowIfCancellationRequested();
                await this.store.RemoveAllAsync(entities, cancellation).DontMarshallContext();
            }
        }
Esempio n. 14
0
        /// <inheritdoc />
        public async Task RemoveAsync <TEntity>(
            TEntity entity, CancellationToken cancellation = default(CancellationToken))
            where TEntity : class
        {
            IAsyncStoreContracts.RemoveAsync(entity);

            cancellation.ThrowIfCancellationRequested();
            using (await this.Lock.WriterLockAsync(cancellation).DontMarshallContext())
            {
                cancellation.ThrowIfCancellationRequested();
                await this.store.RemoveAsync(entity, cancellation).DontMarshallContext();
            }
        }