我有2个Linq查询按国家和部门过滤员工,如下所示:
Dim employeesTableCountry = From employee In dataSource
Where employee.country = selectedCountry
Select employee
Dim employeesTableDepartment = From employeeDepartment In dataSource
Where employeeDepartment.department = selectedDepartment
Select employeeDepartment
我正在尝试合并这两组以制作一个最终的过滤集:
Dim finalTable = employeesTableCountry.Intersect(employeesTableDepartment)
但是,当我这样做时,我收到以下异常消息:
System.InvalidCastException: Unable to cast object of type 'd__92`1[VB$AnonymousType_0`3[System.Data.DataRow]]' to type 'System.Data.EnumerableRowCollection`1[VB$AnonymousType_0`3[System.Data.DataRow]]'
d__92的含义是什么?如何修复此错误?
答案 0 :(得分:0)
我通过手动输入我的最终表格解决了我的问题:
Dim finalTable As System.COllections.Generic.IEnumerable(Of System.Data.DataRow)