我正在尝试提取一组在一组数据中多次出现的记录。我的问题是我的查询没有考虑到初始查询的分组,基本上是在提取所有记录。我有一个初始查询,它从数据表中提取数据,如下所示:
Dim eDTKBase = From eDTKData In dteDTK _
Select New With _
{ _
.eDTK_PDP_Code = eDTKData.Field(Of String)("PDP_CODE"), _`
.eDTK_PDP_Description = eDTKData.Field(Of String)("PDP_DESCRIPTION"), _
.eDTK_WB_Slave = eDTKData.Field(Of String)("WALLBOARD_OR_SLAVE"), _
.eDTK_Print_On_DAD = eDTKData.Field(Of String)("PRINT_ON_DAD"), _
.eDTK_PLI = eDTKData.Field(Of String)("COMPASS_PLI"), _
.eDTK_Dead = eDTKData.Field(Of String)("DEAD"), _
.eDTK_Instance = eDTKData.Field(Of String)("COUNTRY_INSTANCE") _
}
然后,我尝试使用以下 LINQ 查询仅针对由 eDTK_PLI、eDTK_PDP_Code 字段分组的记录筛选其中 eDTK_PDP_Code 字段的计数大于 1 的记录:
Dim EDTKMultPDPtoPLI = From EDTK In eDTKBase _
Group By EDTK.eDTK_PLI, _
EDTK.eDTK_PDP_Code _
Into g = Group _
Where eDTK_PDP_Code.Count > 1 _
Select eDTK_PLI, _
eDTK_PDP_Code, _
eDTK_PDP_Code.Count
问题是它正在评估数据表中的整个数据集,而不仅仅是分组记录。我在这里做错了什么?谢谢。