/// <inheritdoc/> public async Task <IDocumentInfo <T> > AddAsync <T>(T newItem, CancellationToken ct, string id, OperationOptions options) { return(await Retry.WithExponentialBackoff(_logger, ct, async() => { try { return new DocumentInfo <T>(await this._db.Client.CreateDocumentAsync( UriFactory.CreateDocumentCollectionUri(_db.DatabaseId, Container.Id), DocumentCollection.GetItem(id, newItem, options), options.ToRequestOptions(_partitioned), false, ct)); } catch (Exception ex) { FilterException(ex); return null; } })); }
/// <inheritdoc/> public async Task DeleteAsync(string id, CancellationToken ct, OperationOptions options, string etag) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } await Retry.WithExponentialBackoff(_logger, ct, async() => { try { await _db.Client.DeleteDocumentAsync( UriFactory.CreateDocumentUri(_db.DatabaseId, Container.Id, id), options.ToRequestOptions(_partitioned, etag), ct); } catch (Exception ex) { FilterException(ex); return; } }); }
/// <inheritdoc/> public async Task <IDocumentInfo <T> > ReplaceAsync <T>(IDocumentInfo <T> existing, T newItem, CancellationToken ct, OperationOptions options) { if (existing == null) { throw new ArgumentNullException(nameof(existing)); } options = options ?? new OperationOptions(); options.PartitionKey = existing.PartitionKey; return(await Retry.WithExponentialBackoff(_logger, ct, async() => { try { return new DocumentInfo <T>(await this._db.Client.ReplaceDocumentAsync( UriFactory.CreateDocumentUri(_db.DatabaseId, Container.Id, existing.Id), DocumentCollection.GetItem(existing.Id, newItem, options), options.ToRequestOptions(_partitioned, existing.Etag), ct)); } catch (Exception ex) { FilterException(ex); return null; } })); }
/// <inheritdoc/> public async Task <IDocumentInfo <T> > FindAsync <T>(string id, CancellationToken ct, OperationOptions options) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } try { return(await Retry.WithExponentialBackoff(_logger, ct, async() => { try { return new DocumentInfo <T>(await _db.Client.ReadDocumentAsync( UriFactory.CreateDocumentUri(_db.DatabaseId, Container.Id, id), options.ToRequestOptions(_partitioned), ct)); } catch (Exception ex) { FilterException(ex); return null; } })); } catch (ResourceNotFoundException) { return(null); } }