Hi!
I have on array of dictionaries. I need to select one from the array, based on certain dictionary value.
E.g.
array contains [dict1,dict2]
dict1 contains “id”:“123”, “somejsoncontent”:“{xxxx…}”
dict2 contains “id”:“456”, “somejsoncontent”:“{yyyy…}”
I need to assign to a dictionary variable one of the dictionaries, dict1 or dict2, based on the id.
Tried to write some Select functions, but not able to get it fully working.
array.Select(Function(x) x.item(“id”).Equals(“123”)) returns Enumerable.WhereSelectArrayIterator<Dictionary<string, object>, bool> { true, false }
but it is not quite there yet
we keep in mind that a where Operators can have an result of 0,1 or many items
Operators like First, Last will return the defined element or will throw an exception
the FirstOrDefault, LastOrDefault will return the DataType default value, when return is empty. In your case it would return Null / Nothing as Default Value