-
Notifications
You must be signed in to change notification settings - Fork 23
Description
When you send a json to patch, when the json has fields missing from the model, when it is a class, the exception "System.InvalidOperationException : Sequence contains no matching element" is thrown.
To reproduce it, go to the unit test Morcatko.AspNetCore.JsonMergePatch.Tests.NewtonsoftJson.Patching.Attributes.CannotPatchSubObject and change
"{'obj_property': { 'id': 3 }}");
to
"{'obj_other_property': { 'id': 3 }}");
I tracked it down to Morcatko.AspNetCore.JsonMergePatch.Internal.ReflectionHelper.GetJsonProperty which calls Single on properties list and the list is missing the specified property.
I think it would be useful to be able to patch a json with a document that has a random json inside - as when you have a document DB as a storage, you don't always need to have a strongly typed structure to store it.
Maybe, there are alternatives in how to do it?