title: return a list of objects in c# (paging)
body: <p>I am trying to return a list of data along with the total number of records in a json format for extjs paging toolbar. extjs looks for "count" in order to calculate the total number of paging. This is the format I want.</p>
  
  <pre><code>{
    "count": 1,
    "listData": [
        {
            "LastName": "Beckham",
            "FirstName": "David"
        }
    ]
  }
  </code></pre>
  
  <p>This is my method</p>
  
  <pre><code>    public static List&lt;myList&gt; newRecords(int start, int limit)
      {
          List&lt;myList&gt; listData = new List&lt;myList&gt;();
          using (SqlConnection con = SqlTools.GetSqlConnection())
          {
              con.Open();
              SqlCommand cmd = con.CreateCommand();
              cmd.CommandText = "id1_GetData";
              cmd.CommandType = CommandType.StoredProcedure;
              cmd.Parameters.Add("@limit", SqlDbType.Int).Value = limit;
              cmd.Parameters.Add("@start", SqlDbType.Int).Value = start;
  
              SqlDataReader reader = cmd.ExecuteReader();
  
              while (reader.Read())
              {
                  myList list1 = new myList();
  
                  list1.LastName = reader["LastName"].ToString().Trim();
                  list1.FirstName = reader["FirstName"].ToString().Trim();
                  listData.Add(list1);
              }
              con.Close();
              int count = countRecords(); //counts total number of records in db
              var pagingData = (new
              {
                  count,
                  listData
              });
  
              //return myList;
              return new List&lt;myList&gt;(pagingData);
          }
      }
  </code></pre>
  
  <p>This way I get nothing... If I return myList, I only get the first page. please help</p>