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.

2 thoughts on “In Azure DocumentDB, DocumentClient.CreateDocumentQuery doesn’t exists!

  1. Pingback: Querying Collections with DocumentDB Studio | Vincent-Philippe Lauzon's blog

  2. Pingback: DocumentDB Async Querying & Streaming | Vincent-Philippe Lauzon's blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s