title: Custom SQL in Entity Framework, results are objects of null
body: <p>I'm trying to run a custom SQL query in entity framework and bring the results in a specific class. Unfortunately the object inside comes null. </p>
  
  <p>Here is what i tried.</p>
  
  <p>I've declared the class that describes the object.</p>
  
  <pre><code> public class reportReservationReport
      {
          public string Code;
          public string UserName;
      }
  </code></pre>
  
  <p>Then i run the custom query and try to assign to the object.</p>
  
  <pre><code>string sqlQuery = "select ReservationPackages.Code, UserName " +
                            "FROM ReservationPackages " ;
  
          var queryResult = DB.Database.SqlQuery&lt;reportReservationReport&gt;(sqlQuery);
          var query = from pro in queryResult
                      select new reportReservationReport() { Code = pro.Code, UserName = pro.UserName };
  
          List&lt;reportReservationReport&gt; results = query.ToList();
  
  
  
          string test = results[0].Code;
  </code></pre>
  
  <p>test is coming null.</p>
  
  <p>For the above example, the query returns correct data and ReservationPackages.Code has actual  populated.</p>