Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 267
Cowborg Avatar asked Sep 17 '25 22:09

Cowborg


1 Answers

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

like image 182
Kiran Kolli Avatar answered Sep 19 '25 23:09

Kiran Kolli