Description
From @gilmishal on Monday, June 5, 2017 12:34:10 PM
I need to be able to add/remove object from a subcollection of my item - imagine the following json patch string
{"op":"remove", "path":"/a/b/123"}]
or
{"op":"add","path":"/a/b", "value":"{"a":"b"}"
where 123 is my database Index, and not a list position (which my client has no actual way of knowing about)
As of now, I see no way of actually implementing this (maybe I missed something, but I went through the code of both ListAdapter, and DictionaryAdapter).
If I use a Dictionary as the model, the remove operation will work, but the add will not (I could have the client send fake ids, but that would be really odd)
If I use a List as the model, well I won't be able to remove by a database Index (I could order the values in the exact same way the client does, but again - this is odd).
Implementing IObjectAdapter
myself isn't a good option either - besides the fact that it isn't generic, and won't allow me to use multiple IObjectAdapter
s via DI - it takes a lot of code to actually implement properly, and will basically be copying your code with minor changes.
I don't expect it to be able to actually search a list by an Id property, but I do think this entire package should be more configurable to actually allow me to define how to search a list with a given index, without copy pasting your code and applying basic changes.
Copied from original issue: aspnet/JsonPatch#85