We aim to add a new string field named FlagId
to a document from the Countries
collection. We arbitrarily choose the document with the ID as country/1005
(France) to apply the patch command. For that you will add the PatchingDocument()
method to the Program
class and then execute it.
Start Visual Studio and open the
RavenDB_Ch06
project.Add the following code to the
Main()
method:Save all the files, build and run the solution.
In Windows Explorer, switch to RavenDB prompt window to look at its logs.
You just patched one item from the Countries
collection by calling the Patch()
method on the DatabaseCommands
object. This patch operation aims to add the FlagId
property to the Country
field with the ID as country/1005
.
In the previous code snippet (line 146) you call this method providing the document key (country/1005
) to patch.
The Patch()
method requests an array of PatchRequest
object, you create a new...