Best way to convert a huge collection of key value pairs to C# object

I have a web service that returns an object with multiple child objects. The parent object as well as the child object has a huge array of key value pairs (keyvaluepair[]). At this moment I am using linq to identify the keyvaluepair and then get the value.

For a smaller collection this process seems to be okay. But the object I am receiving from the service has more than 300 key value pairs and I am searching for an optimal way to map the key value pairs to my object.

Is there any good way to do this or any existing library that can help me do this?

Jon Skeet
people
quotationmark

It sounds like you should just build a dictionary:

var dictionary = pairs.ToDictionary(pair => pair.Key, pair => pair.Value);

Then you can look up any entry by key very efficiently. Note that this requires that all the keys are distinct. If there can be multiple values for a key, use ToLookup instead.

people

See more on this question at Stackoverflow