我已经使用linq编写了一个查询到Datatable,但我不知道用于声明变量queryArchi
的类型是什么?我尝试过类型System.Data.EnumerableRowCollection(Of Object)
,但收到错误消息:
无法投射“WhereSelectEnumerableIterator
类型的对象2 [VB $ AnonymousType_8
9
代码:
Dim queryArchi As System.Data.EnumerableRowCollection(Of Object)
Dim queryStructure
If tf = 0 Then
queryArchi = (From b In DataBien.AsEnumerable()
Group b By b!code_projet, b!code_operation, b!code_type, b!Designation_part, b!code_part Into Group
Select code_projet, code_operation, code_type, NBP = Group.Count())
Else
queryArchi = (From b In DataBien.AsEnumerable()
Group b By b!code_projet, b!code_operation, b!code_type, b!Designation_part, b!code_part, b!Titré Into Group
Select code_projet, code_operation, code_type, Titré, NBP = Group.Count())
End If
If vil <> "" Then queryArchi = queryArchi.Where(Function(d) d.code_projet = vil)
queryStructure = queryArchi.ToList