Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Azure DocumentDB

You're reading from   Learning Azure DocumentDB Create outstanding enterprise solutions around DocumentDB using the latest technologies and programming tools with Azure

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781783552467
Length 152 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Riccardo Becker Riccardo Becker
Author Profile Icon Riccardo Becker
Riccardo Becker
Arrow right icon
View More author details
Toc

Updating documents

After executing some basic SELECT queries against our collection, it is time to do some updating. This means looking up the document, changing information, and saving it to the collection. Consider the following C# code snippet:

Updating documents

In the following code snippets, we will update a document, set a new date of birth, and save the document to the collection.

Note

To enable faster processing, we store the DateTime fields as epoch values so that range queries are executed efficiently.

I used information from the official Azure blogs (http://azure.microsoft.com/blog/2014/11/19/working-with-dates-in-azure-documentdb-4/) to create the following code snippet. Instead of comparing dates, the corresponding epoch values are compared inside the query. First, a document is retrieved from the collection using a filter on the first and last name. A new date of birth value is created and written back to the collection. The code is as follows:

var documentByLinq = (from c in client...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image