Morcatko / Morcatko.AspNetCore.JsonMergePatch

JsonMergePatch support for ASP.NET Core
MIT License
88 stars 21 forks source link

Can't Patch objects with object properties #34

Closed AnsonSmith closed 4 years ago

AnsonSmith commented 4 years ago

For a objects that contains properties of other class types (not inbuilt .net types) I am receiving the following error:

System.InvalidOperationException : Sequence contains no matching element

Gist to repro is here: https://gist.github.com/AnsonSmith/c81b042231d4031485f249f2a49bf9ee

Not sure if I'm doing something wrong, or if there is a real issue here.

Thanks, Anson

Morcatko commented 4 years ago

This is a bug in code.

The problem is your JSON property (obj_property) has different name than your C# property (ObjProperty) As a workaround you have to use same names (case is ignored)

I will try to fix it, but I can't promise any date.

The bug is in ReflectionHelper.GetPropertyInfo() - property.Name.Equals(propertyName) must respect JSON namings

Morcatko commented 4 years ago

This was fixed in v3.0.5