title: Dapper.NET filling a class in "list of class"
body: <p>I am new on Dapper.NET kinda stuck on this. I am trying to fill a class which has another class from multirow result set.</p>
  
  <p># DATABASE SP > </p>
  
  <pre><code>SELECT b.BuildingId, b.BuildingName, b.Wood, b.Food, b.Stone, b.Gold FROM UserBuildings ub, Buildings b WHERE b.BuildingId = ub.BuildingId AND UserId = @UserId
  </code></pre>
  
  <p># CODE ></p>
  
  <pre><code>    using (IDbConnection connection = OpenConnection())
      {
          List&lt;Building.Building&gt; buildings = new List&lt;Building.Building&gt;();
  
          var multi = connection.QueryMultiple&lt;Building.Building, Resource.Resource&gt;("UserBuildingGet", new { UserId = UserId }, commandType: CommandType.StoredProcedure).ToList();
  
          building.Resource = multi.Read&lt;Resource.Resource&gt;().Single();
  
          return building;
      }
  </code></pre>
  
  <p># CLASSES > </p>
  
  <pre><code>public class Building
  {
      private int _BuildingId;
      private string _BuildingName;
      private Resource.Resource _Resource;
  
  public int BuildingId
  {
      get { return _BuildingId; }
      set { _BuildingId = value; }
  }
  public string BuildingName
  {
      get { return _BuildingName; }
      set { _BuildingName = value; }
  }
  public Resource.Resource Resource
  {
      get { return _Resource; }
      set { _Resource = value; }
  }
  
  public Building(int BuildingId, string BuildingName, Resource.Resource Resource)
  {
      this.BuildingId = BuildingId;
      this.BuildingName = BuildingName;
      this.Resource = Resource;
  }
  }
  
  public class Resource
  {
      private int _Wood;
      private int _Food;
      private int _Stone;
      private int _Gold;
  
  public int Wood
  {
      get { return _Wood; }
      set { _Wood = value; }
  }
  public int Food
  {
      get { return _Food; }
      set { _Food = value; }
  }
  public int Stone
  {
      get { return _Stone; }
      set { _Stone = value; }
  }
  public int Gold
  {
      get { return _Gold; }
      set { _Gold = value; }
  }
  
  public Resource(int Wood, int Food, int Stone, int Gold)
  {
      this.Wood = Wood;
      this.Food = Food;
      this.Stone = Stone;
      this.Gold = Gold;
  }
  </code></pre>
  
  <p>}</p>