How to convert dataset into IEnumerable collection

Posted by Ravyii under C# category on | Points: 40 | Views : 10931
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")


Comments or Responses

Posted by: T.Saravanan on: 3/4/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi ravyii,

Welcome to DNF.

Nice start. Kindly post your code inside the code tag.

Login to post response