Home > ADO.NET > Convert a dataset into IEnumerable

Convert a dataset into IEnumerable


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:
  1. June 7, 2012 at 2:50 PM

    WONDERFUL Post.thanks for share..more wait

  2. June 9, 2012 at 6:01 PM

    thanks for comment webdesignsolutions-cr.com – porfolio, be tuned with this blog i coming with some more insight on latest technology , you can follow for update emailed directly to your mail box

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: