Пример #1
0
        public async Task InsertOneAsync(InsertOneModel <TDocument> model, TimeSpan?timeout, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(model, "model");

            try
            {
                var bulkModel = new BulkWriteModel <TDocument>(new[] { model });
                await BulkWriteAsync(bulkModel, timeout, cancellationToken);
            }
            catch (BulkWriteException <TDocument> ex)
            {
                throw WriteException.FromBulkWriteException(ex);
            }
        }
Пример #2
0
        public async Task <UpdateResult> UpdateOneAsync(UpdateOneModel <TDocument> model, TimeSpan?timeout, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(model, "model");

            try
            {
                var bulkModel = new BulkWriteModel <TDocument>(new[] { model });
                var result    = await BulkWriteAsync(bulkModel, timeout, cancellationToken);

                return(UpdateResult.FromCore(result));
            }
            catch (BulkWriteException <TDocument> ex)
            {
                throw WriteException.FromBulkWriteException(ex);
            }
        }