Archive

Archive for the ‘ADO.NET’ Category

Convert a dataset into IEnumerable

June 5, 2012 2 comments

convert a dataset information into a IEnumerable collection
Create a user class
public class User
{
public int UserID { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}

private List<User> userList = null;
userList = dataSet.Tables[0].AsEnumerable()
.Select(row => new User
{
UserID = row.Field<int>(“userid”),
UserName = row.Field<string>(“username”),
Password = row.Field<string>(“password”)
}).ToList();

}
if it help , leave a comment please.

Advertisements
Categories: ADO.NET Tags:
%d bloggers like this: