Well, just create a class that has all database columns as properties. Then just create an instance of ICollection (List, Hashset, etc.) and populate it (using LINQ, for example).
public class Customer
{
public int Id { get; set;}
public string Name { get; set; }
public Customer(int id, string name)
{
this.Id = id;
this.Name = name;
}
}
And do something like:
List<Customer> customers = new List<Customer>();
using (DbDataReader reader =
{
while (reader.Read())
{
Customer customer = new Customer(reader.GetInt32(0), reader.GetString(1));
customers.Add(customer);
}
}
If you are accessing data stored in a database, you can look at LinqToSql or LinqToEntities.
source
share