title: How to create a Dynamic IEnumerable
body: <p>I know this is a simple question for you. But I am a beginner in c#. 
  What I want to achieve is to create a method that will store any type of List of Objects from my Model. e.g <code>List&lt;Person&gt;</code>.</p>
  
  <p>I have tried to make something like this..</p>
  
  <pre><code>public IEnumerable&lt;T&gt; GetObjects&lt;T&gt;()
  {
      Type type = typeof(T);
  
      PropertyInfo[] properties = type.GetProperties();
  
      foreach (PropertyInfo item in properties)
      {
          // store properties
      }
  
  
      List&lt;T&gt; objects = new List&lt;T&gt;();
  
      using (SqlConnection str = GetSqlConnection)
      {
          // retrieve data from db 
          //then store it to list of objects
      }
  
      return objects;
  
  }
  </code></pre>
  
  <p>This will enable me to retrieve data using only this method.</p>
  
  <p>EDIT:</p>
  
  <p>I already manage to create this sample code to retrieve a specific table from a database.</p>
  
  <pre><code>public IEnumerable&lt;ItemBrand&gt; getAllBrand
  {
      get
      {
          List&lt;ItemBrand&gt; brands = new List&lt;ItemBrand&gt;();
  
          using (MySqlConnection strConn = getMySqlConnection())
          {
              string query = "SELECT * FROM tblbrand";
              MySqlCommand cmd = new MySqlCommand(query, strConn);
  
              strConn.Open();
              MySqlDataReader rd = cmd.ExecuteReader();
  
              while (rd.Read())
              {
                  ItemBrand brand = new ItemBrand();
  
                  brand.brandID = Convert.ToInt32(rd["brandID"]);
                  brand.Name = rd["brandName"].ToString();
  
                  brands.Add(brand);
              }
  
              return brands;
          }
      }
  }
  </code></pre>
  
  <p>Currently I have multiple methods of this in my solution. I would love to remove those duplicate codes with your help.</p>