Consider a scenario we have to convert a datset information into a IEnumerable collection
This is the User Object Class
public class UserVO
{
public int? UserID { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
I am not writing the code for dataset population considering we have a datset which returns a collection of UserVO.
Now i need to conver the DataSet information into the List<UserVO>
public class UserDAO
{
private List<UserVO> userList = null;
userList = dataSet.Tables[0].AsEnumerable()
.Select(row => new UserVO
{
UserID = row.Field<int?>("userid"),
UserName = row.Field<string>("username"),
Password = row.Field<string>("password")
}).ToList();
}