c# - Convert DataSet to List -


here c# code

employee objemp = new employee(); list<employee> emplist = new list<employee>(); foreach (datarow dr in ds.tables[0].rows) {     emplist.add(new employee { name = convert.tostring(dr["name"]), age = convert.toint32(dr["age"]) }); } 

it uses loop create list dataset.is there direct method or shorter method or 1 line code convert dataset list

try this:

var emplist = ds.tables[0].asenumerable().select(datarow => new employee{name = datarow.field<string>("name")}).tolist(); 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -