title: How to convert key value pair to a custom object list
body: <p><a href="https://i.stack.imgur.com/EXK3C.png" rel="nofollow noreferrer">enter image description here</a>I have a keyValupair of <code>Hotel</code> details;:</p>
  
  <p>//This is where the data comes from : -</p>
  
  <pre><code>   JavaScriptSerializer json_serializer = new JavaScriptSerializer();
              dynamic hotels1 = (dynamic)json_serializer.DeserializeObject(jso);
  var keyValuePairs = hotels1["hotels"];
  
  var hotelList = keyValuePairs["hotels"];   // hotelList[0]  ={'key'='Code' ;value='123'} 
                                             //{'key'='Name' 
                                             // ;value='Sheraton'}  
  </code></pre>
  
  <p>how do i convert this to a list of <code>Hotel</code></p>
  
  <pre><code>List&lt;Hotel&gt; hotaals = new List&lt;Hotel&gt;();
  </code></pre>
  
  <p>where <code>Hotel</code> is</p>
  
  <pre><code>public class Hotel
  {
      public int code { get; set; }
      public string name { get; set; }
  }
  </code></pre>
  
  <p>I use a for loop to map fields, but my great boss says its inefficient and i have to use Linq.</p>
  
  <p>The loop i use</p>
  
  <pre><code>    foreach (dynamic h in hotelList)
      {
  
          oneHotel = new Hotel();
          oneHotel.code = h["code"];
          oneHotel.name = h["name"];
    myHotels.Add(oneHotel);
   }
  </code></pre>