问题描述
是否有任何可能的方法比循环,枚举ICollection将它们分别转换为知道ICollection中的列的Typed List。我正在使用.net Framework 2.0,C#2.0。预期的答案是这样的,一个班轮
List< Bills> bills = GetBills(DataView / DataRowView / ICollection);
其中 Bills
type会具有 BillNumber,BillDate,BilledTo
作为属性。 DataRowView / DataView将具有相应的包含记录的列。是否有工厂构建方法可以完成工作?如果没有任何一个班轮做到这一点?
你可以在一行中使用LINQ选择一个lambda吗?沿着这些线...... ....
List< Bills> bill = yourDataView.Rows.Select(t => new Bills(){BillNumber = t [BillNumber],BillDate = t [BillDate],BilledTo = t [BilledTo]})。
Is there any possible method than looping, Enumerating the ICollection to convert them respectively to Typed List knowing the columns in the ICollection. I am using .net Framework 2.0, C#2.0. Expected answer would be something like this,a one liner
List<Bills> bills = GetBills(DataView/DataRowView/ICollection);
where Bills
type would have BillNumber, BillDate, BilledTo
as properties. The DataRowView/DataView would have corresponding Columns with records in them. Is there a factory build method that does the Job? If No any one liner to do it?
Could you do it in one line using a LINQ Select with a lambda? Something along these lines....
List<Bills> bills = yourDataView.Rows.Select(t => new Bills() {BillNumber = t["BillNumber"], BillDate = t["BillDate"], BilledTo = t["BilledTo"]}).ToList();
这篇关于如何将DataView,DataRowView转换为泛型类型列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!