Book Image

Learning Azure DocumentDB

By : Riccardo Becker
Book Image

Learning Azure DocumentDB

By: Riccardo Becker

Overview of this book

Learning DocumentDB adopts a practical, step-by-step approach to help you learn the basics of DocumentDB and use your new-found abilities in real-life scenarios and enterprise solutions. We start with the absolute basics, such as setting up a DocumentDB environment, and guide you through managing your databases, and executing simple and complex queries. Next, we explain how to work with DocumentDB using the open REST protocol, and demonstrate how JavaScript works with DocumentDB. We’ll also show you how to authenticate and execute queries. Moving on, you’ll find out how to use DocumentDB from within Node.js to kick-start your Node.js projects. Next, you’ll discover how to increase the performance of your DocumentDB database and fine-tune it. Finally, you’ll get to grips with using DocumentDB in conjunction with other services offered from the Microsoft Azure platform.
Table of Contents (15 chapters)
Learning Azure DocumentDB
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using LINQ to DocumentDB


We have already seen some aspects of LINQ to DocumentDB in previous chapters but in this section we describe it in much more detail. We have seen ways to query our database using SQL and JavaScript or directly on the portal.

Microsoft have also provided a .NET SDK for DocumentDB that includes a LINQ provider. LINQ is used by many developers and architects because it offers a programming model that is consistent across different underlying databases or stores. The a LINQ provider translates LINQ query to a DocumentDB query, reducing the complexity for the programmer. Instead of executing raw SQL queries against DocumentDB, we can create an IQueryable object that queries the DocumentDB query provider. The provider translates the LINQ query into an SQL query and executes it. The result set that contains the JSON is then deserialized into a .NET object on the client.

For example, the following LINQ statement is translated to DocumentDB SQL:

query.Where (p => p.LastName...