Home > database >  Cosmos DB "Partial Update"/Patch, cant set new property value to null
Cosmos DB "Partial Update"/Patch, cant set new property value to null

Time:12-02

I'm trying out the Cosmos DB SDK's new Patch/Partial Update-functionality (for .NET)

When adding a new property I use

 var patchOperations = new List<PatchOperation>(){
       PatchOperation.Add<string>("/FavoriteColor", **null**)
 };


 await container.PatchItemAsync<T>(
                          id: myId,
                          partitionKey: new PartitionKey(myPk),
                          patchOperations: patchOperations);

The problem is, that it throws at the PatchOperation-Add() if I set second parameter to null (with message "Value cannot be null"). I can set any non-null string and it works well. I just wonder if this isn't supported yet or if I missed something.

CodePudding user response:

Remove is one alternative if the intent is to remove field/property.

CodePudding user response:

This is not supported with Patch yet,

However, if you want to remove the entire property you need to use Remove Operation

  • Related