protected async Task <IMongoCollection <TEntity> > GetCollectionAsync(CancellationToken cancellationToken) { if (_collection.Value != null) { return(_collection.Value); } _collection.Value = await _context.GetCollectionAsync <TEntity>(cancellationToken); return(_collection.Value); }
/// <summary> /// Gets the Mongo collection that backs this repository. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> protected async Task <IMongoCollection <TEntity> > GetCollectionAsync(CancellationToken cancellationToken = default) => await _context.GetCollectionAsync <TEntity>(cancellationToken);