I have one situation where A method runs some LINQ Query on a JArray and returns me an IEnumerable.
On top of that I want to run a JSONPATH Query using the SelectTokens method, but the SelectToken method is obviously not available on IEnumerable<>.
So what I have done was simply created an JArray out of the IEnumerable.
new JArray(myIEnumerable);
The Problem is that when I do this, the elements are copied, but I would really need to have them as reference (preserving same Hashcode).
I tried many different cases from setting PreserveReferencesHandling on SerializerSettings or by trying to add items manually...
var myNewArray = new JArray();
foreach(var item in myIEnumerable)
{
myNewArray.Add(item);
//item.GetHashCode not the same as the just added item!!!! :-(
}
As I really need to keep the reference while still being able to call the JSonPAth(SelectToken, SelectTokens), does anyone have an idea how could I achive this?
Best Regards,
PCBL