title: RestSharp and OData - Issue Deserializing JSON
body: <p>My team and I are working on a project with OData. We are trying to use the RestSharp client but cannot find any clean example of a best practice on using it with OData in C#. </p>
  
  <p>The issue we are having is that when trying to get the data it is 2 layers of JSON we think.</p>
  
  <pre><code>private T execRequest&lt;T&gt;(RestClient client, RestRequest request, bool retry = true)
      {
          IRestResponse response;
          T resultdata = default(T);
          try
          {
              response = client.Execute(request);
          }
          catch (Exception)
          {
              throw;
          }
          if (response.StatusDescription == "OK") // TAKE CARE OF Session expired or invalid
          {
              resultdata = JsonConvert.DeserializeObject&lt;T&gt;(response.Content);
          }
  
  
         return resultdata;
      }
  </code></pre>
  
  <p>In this result if we use a simple Type like Person (ID,enabled,active) we see the data in response.content. </p>
  
  <blockquote>
    <p>"{\"@odata.context\":\"<a href="http://localhost:56460/" rel="nofollow noreferrer">http://localhost:56460/</a>$metadata#Person\",\"value\":[{\"ID\":1090,\"enabled\":true,\"active\":false}]}"</p>
  </blockquote>
  
  <p>However resultdata does not actually get the data...it initializes the object but ID, enabled and active are 0, false, false.</p>
  
  <p>We are fairly new to this...my feeling though is that since the response back is not 100% the json data might be the issue?</p>
  
  <p>(p.s. also looking for a some doc's pertaining to OData and RESTSharp).</p>
  
  <p>edit: We are thinking that we need to deserialize to a higher level object since the data in response.content is an object, then the object per say. We are trying to find a clean example of this with OData but have not yet.</p>