Skip to content

Instantly share code, notes, and snippets.

View tsubaki961's full-sized avatar

Naoaki Yamaguchi tsubaki961

View GitHub Profile
private List<T> ConvertToList<T>(DataTable dt)
{
var columns = dt.Columns.Cast<DataColumn>()
.Select(c => c.ColumnName)
.ToList();
var properties = typeof(T).GetProperties();
return dt.AsEnumerable().Select(row => GetT<T>(row, columns, properties)).ToList();
}