In Azure DocumentDB, DocumentClient.CreateDocumentQuery doesn’t exists!

This is a quick help for you out there who are developing against Azure DocumentDB in .NET.

Maybe you read the Getting Started guide or you found that line of code somewhere else.

var families = client.CreateDocumentQuery(documentCollection.DocumentsLink, "SELECT * " + "FROM Families f " + "WHERE f.id = \"AndersenFamily\"");

Then you try this at home only not to find the said CreateDocumentQuery on the class Microsoft.Azure.Documents.Client.DocumentClient.

No it isn’t there. It isn’t because this is a preview service and the doc is out-of-date. It is a good old Linq / extension methods trick.

You need to add the line

using Microsoft.Azure.Documents.Linq; 

at the beginning of your code. This way the code snippet above will actually pick up the extension methods class Microsoft.Azure.Documents.Linq.DocumentQueryable.


Leave a comment