datarowcollection

Map RowDataCollection to DTO using AutoMapper

倖福魔咒の 提交于 2019-12-08 07:46:47
问题 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

Will Microsoft ever make all collections useable by LINQ?

夙愿已清 提交于 2019-12-06 21:12:34
问题 I've been using LINQ for awhile (and enjoy it), but it feels like I hit a speedbump when I run across .NET specialized collections(DataRowCollection, ControlCollection). Is there a way to use LINQ with these specialized controls, and if not do you think Microsoft will address this in the next release of the framework? Or are we left to iterate over these the non-LINQ way, or pull the items out of the collection into LINQ-able collections ourselves? 回答1: The reason why collections like

Get distinct values from a column of DataTable in .NET 2.0

倾然丶 夕夏残阳落幕 提交于 2019-12-01 23:15:51
问题 I am working on a legacy project which was developed using .NET Framework 2.0. In this project, I get distinct values from DataRowCollection by ItemNo column. I am only interested in ItemNo . The DataRow consist of ItemNo , Qty and Date . I am thinking of iterating the DataRowCollection and adding the unique ItemNo into a list of string as below (not tested) var items = new List<string>(); foreach (DataRow orderItem in rows) { var itemNo = orderItem["ITEMNO"].ToString().Trim(); if(items.Find

Get distinct values from a column of DataTable in .NET 2.0

a 夏天 提交于 2019-12-01 21:20:19
I am working on a legacy project which was developed using .NET Framework 2.0. In this project, I get distinct values from DataRowCollection by ItemNo column. I am only interested in ItemNo . The DataRow consist of ItemNo , Qty and Date . I am thinking of iterating the DataRowCollection and adding the unique ItemNo into a list of string as below (not tested) var items = new List<string>(); foreach (DataRow orderItem in rows) { var itemNo = orderItem["ITEMNO"].ToString().Trim(); if(items.Find(delegate(string str) { return str == itemNo ;}) == null) { items.Add(itemNo); } } Is there a better way