The IDocumentClient interface does not currently expose the ReadDocumentAsync<T> methods that are offered by the DocumentClient class. These overloads would be useful and, AFAICT, far more efficient than having to use LINQ based querying API for reading single document instances into the exact type T that we need. The interface does expose the non-generic ReadDocumentAsync methods, so this just looks like an oversight.
I don't want to have to sacrifice using the IDocumentClient interface to get this functionality as I've found it extremely useful to be able to rely on the abstraction that the interface provides for the purposes of mocking while unit testing my repository layer.
+1 - this is a must for Mocking and testing. I believe there are additional missing interface methods, such as CreateDatabaseIfNotExistsAsync. Seemingly at present, coupling to interface only, we need to hack by downcasting the interface to access the method.
+1 CreateDocumentCollectionIfNotExistsAsync too.
All of the IfNotExistsAsync methods are missing, would be great to have the full public API on DocumentClient added to IDocumentClient for easier mocking.
is there any ETA for this ?
CreateDocumentCollectionIfNotExistsAsync is also one of the missing action!
+1 would like to see ReadDocumentAsync
Yeah its a little weird because we're supposed to create a singleton of the client accross your application, yet we can't effectively use the IDocumentClient provided without doing some hacky casting. Hopefully it is resolved soon.
Any news on this?
there is another issue: IDocumentQuery and IDocumentQuery<T> do not derive from IQueryable and IQueryable<T>, while their implementations do. This causes not only additional typecasting, but also makes unit testing much harder.
As per following this method is available :
https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.client.documentclient.readdocumentasync?view=azure-dotnet#Applies_to
But still not found while i had installed latest package Microsoft.Azure.DocumentDB 1.20.0
Its only available in DocumentDBClient class not IDocumentDBClient interface. Wonder why its not in the interface.
The 2.0.0-preview version of the package appears to have addressed some of those issues.
However, it would be nice for the DoucmentDB team to actually respond to this issue to let us know that it is being worked on, considering the source code for the package is still not published in GitHub.
@AdrianSanguineti
Open source Microsoft's plan for DocumentDB Client .NET SDK is uncertain.
This feedback has no answer.
https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/18902368-opensource-documentdb-net-sdk
@kirankumarkolli Do you have any timeline or plan? The following Place Folder remains empty for about 4 years.
https://github.com/Azure/azure-documentdb-dotnet/tree/master/sdk
OpenAsync() is another method not defined on the IDocumentClient interface, even in the 2.0.0-preview package.
The Performance Tips article recommends calling it to avoid startup latency: https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips
For ReadDocumentAsync<T>, might try this workaround:
var document = await _documentClient.ReadDocumentAsync(documentUri);
TResource res = (dynamic)document.Resource;
Most helpful comment
OpenAsync()is another method not defined on theIDocumentClientinterface, even in the 2.0.0-preview package.The Performance Tips article recommends calling it to avoid startup latency: https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips