datacolumn由自定义对象选择

时间:2014-05-29 11:13:01

标签: vb.net select datacolumn custom-type

如何从VB.net中的Datatable中选择包含我的自定义对象的所有行? - 实际上它的类型是INotifyPropertyChanged 我考虑将datatable.select方法与过滤器表达式一起使用,但不知道比较如何与select一起使用。

1 个答案:

答案 0 :(得分:0)

尝试使用LINQ的Where方法,例如,

' this will return a list of DataRow object
Dim rows = datatable.AsEnumerable().Where(Function(x) TypeOf x("mycolumn") Is INotifyPropertyChanged).ToList()

OR

' this will return a new DataTable with your selected rows
Dim dt2 = datatable.AsEnumerable().Where(Function(x) TypeOf x("mycolumn") Is INotifyPropertyChanged).CopyToDataTable()