Map RowDataCollection to DTO using AutoMapper
问题 Is there a way to map a RowDataCollection to DTO using AutoMapper? Here is a scenario: DataRow to Object user.UserId = row["UserId"]; user.UserName = row["UserName"]; 回答1: glbal.asax configuration Mapper.CreateMap<DataRow, EventCompactViewModel>() .ConvertUsing(x => (EventCompactViewModel)AutomapperExtensions.DataRowMapper(x, typeof(EventCompactViewModel), null)); Data row mapper public static object DataRowMapper(DataRow dataRow, Type type, string prefix) { try { var returnObject = Activator