Join GitHub today
Adding/Removing from a collection by an index value #85
I need to be able to add/remove object from a subcollection of my item - imagine the following json patch string
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).
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.
@gilmishal I need this for my projects, and I'm working on my own solution now.
Although not ideal, I must take this approach since the issue would otherwise be blocking me.
I can't sit around waiting, but I do have an initial suggestion for introducing a little more fine-grained extensibility into the library. The
Alternatively, instead of the base factory class, it could be an interface. The
Come to think of it, are there really any scenarios for customizing the
The central issue is that we're dealing with entities rather than JSON objects. I've described my solution at json-patch/json-patch2#20. I hope that my suggestion there can become an RFC. In the meantime, and in case that doesn't happen, we at least @Eilon need better extensibility. How are other people using this library? I and I assume @gilmishal are using it with EF Core, which is also part of ASP.NET Core. Allowing these two libraries to be used together should be somewhat of a priority, shouldn't it?