How can map datatable columns with the properties of DTO object of Type T using LINQ query or Lambda expression. This should automatically map with any DTO.
DataTable dt = db.GetEmployees();
foreach(DataRow dr in dt.Rows)
{
var obj = new T();
PropertyInfo[] prop = obj.GetType().GetProperties();
var results = dt.AsEnumerable().Select(dr => new T
{
///How to directly map type T properties in prop with columns in datatable dt
FirstName = ?
//Expecting something like this
//FirstName = columnName of dt here
}
}
Aucun commentaire:
Enregistrer un commentaire