无法转换类型为'WhereSelectEnumerableIterator`2的对象[VB $ AnonymousType_8`9

时间:2017-07-07 14:58:45

标签: vb.net linq query-optimization

我已经使用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

0 个答案:

没有答案