private async Task <BatchIDGenerator> EnsureGenerator() { if (_idGenerator == null) { using (ITransaction tx = await _db.StartTransactionAsync()) { Maybe <EventID> lastID = await _db .UseTransaction(tx) .GetCollection <RecordedEvent>(CollectionName) .Max <EventID>("_id"); _idGenerator = BatchIDGenerator.Create(lastID.OrDefault()); } } return(_idGenerator); }
internal MongoEventStore(IMongoFacade db, EventStoreSettings settings, BatchIDGenerator idGenerator) : this(db, settings) { _idGenerator = idGenerator; }