There is one way.. create entity class having property same like your table columns,
then retrieve data from database in SqlDataReader, then traverse through the SqlDataReader, create an object of entity class assingn the value of each column to rispective property of your object and add the object in List.
eg // assume my table contains only two fields Name and Address
Public Class Student
{
Public string Name
{
get;
set;
}
Public string Address
{
get;
set;
}
Public List<student> GetAllData()
{
List<student> lstStudent = new List<student>();
While(reader.Read())
{
Student obj = new Student();
obj.Name = reader["Name"].ToString();
Obj.Address = reader["Address"].ToString();
lstStudent.Add(obj);
}
return lstStudent;
}
}
</student></student></student>
If the solution is helpful to you the accept the solution