Closed eshkard closed 5 years ago
Hi eshkard, thanks for your message. Yes this is something that can be done. I can change them like so:
private MongoDbUpdater _mongoDbUpdater;
protected MongoDbUpdater MongoDbUpdater
{
get
{
if (_mongoDbUpdater != null) { return _mongoDbUpdater; }
lock (_initLock)
{
if (_mongoDbUpdater == null)
{
_mongoDbUpdater = new MongoDbUpdater(MongoDbContext);
}
}
return _mongoDbUpdater;
}
set
{
_mongoDbUpdater = value;
}
}
Would that be ok for you ? Thanks for the zip file, I will integrate them to the base data accessor and write tests when I have the time :) In the mean time feel free to submit a PR with those changes! As long as they are integration-tested I'm happy to merge :).
I have just updated the code. You can also extend functionalityof your repo without extending the accessors too:
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var filter = Builders<TDocument>.Filter.Eq("Id", modifiedDocument.Id);
var updateRes = await MongoDbUpdater.HandlePartitioned<TDocument, TKey>(modifiedDocument)
.ReplaceOneAsync(session, filter, modifiedDocument, cancellationToken: cancellationToken)
.ConfigureAwait(false);
return updateRes.ModifiedCount == 1;
}
Grate thank's.
By the way forget to send you Base repository extension code ExtendedBaseMongoRepository.zip With simple refactor (aka rename of some properties ) you can integrate it with-in package
Thank's
cool will do, cheers!
Hei Alexandre, Current implementation of BaseMongoRepository does not allow to override MongoDb accessor properties (CUD) can you kindly add setter to: protected MongoDbUpdater MongoDbUpdater { get; } protected MongoDbEraser MongoDbEraser { get; } protected MongoDbCreator MongoDbCreator { get; } protected MongoDbIndexHandler MongoDbIndexHandler { get; }
or allow inject extended functionality from constructor.
The main purpose of extension is to add transaction (MongoDb 4) functionality without many re-wrights in to our existing repositories. ExtendedDataAccess.zip