azure-cosmos-dotnet-repository
azure-cosmos-dotnet-repository copied to clipboard
InMemoryRepository has different implementations per interface
Given you are using the in-memory repository implementation and you make use of the new types IWriteOnlyRepository<T>
and IReadOnlyRepository<T>
if you resolve them both for the same TItem
then say write to using the write-only interface then try and read using the read-only version, then the result will not be found.
I think this is due to the fact that these are registered with a different instance of an InMemoryRepository<T>
per interface.
https://github.com/IEvangelist/azure-cosmos-dotnet-repository/blob/3a3be6b61f88732cc653fd334211c83205b23cc8/src/Microsoft.Azure.CosmosRepository/Extensions/ServiceCollectionExtensions.cs#L97-L113
I think we are best off refactoring the in-memory imp to have a shared store of events that all interfaces can use and interact with.
That makes sense. I always thought that for testing we would have just use a static ConcurrentDictionary
.
A static dictionary would work but if we want to really improve the in memory implementation we should consider implementing some services that store manipulate the data (serialisation/deserialization and etags/ttl/ts) moving some of the storage logic out. This would let us work towards a more realistic implementation.
A static dictionary would work but if we want to really improve the in memory implementation we should consider implementing some services that store manipulate the data (serialisation/deserialization and etags/ttl/ts) moving some of the storage logic out. This would let us work towards a more realistic implementation.
I like it and I agree. How much effort would it take?
It could be a fair bit, it depends how far we want to go. I have started fleshing out a basic implementation. With what is there (and a little extra work) we could fix this bug. Then the framework is there to extend and clean it up. I have raised a POC that I will keep working on. Hopefully will get some time this weekend to take a look.
https://github.com/IEvangelist/azure-cosmos-dotnet-repository/pull/268