Unhandled exception. MongoDB.Driver.MongoCommandException: Command findAndModify failed: Invalid $addFields :: caused by :: FieldPath field names may not start with ‘$’…
The JSON string provided to the BsonDocument.Parse method is invalid. Field names in JSON must be quoted, though many parsers allow unquoted field names if they do not contain special characters such as ., [, and ]. The following properly-quoted JSON does parse correctly, but I believe the resulting MQL is invalid:
Regarding Update 1, this is a problem in your findAndModify command, not in the .NET/C# driver. I would suggest investigating how to express this in the mongosh shell. Providing a self-contained repro (including some simplified sample data) and explanation of what you’re attempting to accomplish would be very helpful in understanding what you are trying to achieve.
Hi @James_Kovacs you always help with C# . Our questing about C# and GUID get top 1 google search result.
Now we current questing move to topic:
If you have time, take a look. there’s a VERY clear and simple example.
We found a complicated answer. But I think there is a simpler , concise answer.