Introduction
In this article we will learn how to convert dataset to list or convert DataSet to List of collection o generic list in c#. Convert DataSet into List using LINQ.
Many times we face this condition when we need to convert our DatSet data into a List of Collection. So here you can find the solution of this Using forach.
Suppose i have a DataSet data looks like give below image
Read here Convert DataList To List Using LINQ - C#
In this article we will learn how to convert dataset to list or convert DataSet to List of collection o generic list in c#. Convert DataSet into List using LINQ.
Many times we face this condition when we need to convert our DatSet data into a List of Collection. So here you can find the solution of this Using forach.
Suppose i have a DataSet data looks like give below image
Read here Convert DataList To List Using LINQ - C#
Employee objEmp = new Employee();
List<Employee> empList = new List<Employee>();
foreach (DataRow dr in ds.Tables[0].Rows)
{
empList.Add(new Employee{
EmpID = Convert.ToInt32(dr["EmpID"]),
EmpName = Convert.ToString(dr["EmpName"])
});
}
|
Here Employee is entity and EmpId and EmpName are its properties which i want to retrieve in List data.
You may also interested Difference between array and ArrayList with example.
0 comments:
Post a Comment