我有一个如下的集合
Private _bankRates As Dictionary(Of RateSourceBank.Key, RateSourceBank)
RateSourceBank.Key只是
Public Class Key
Public RateType As String
Public EffectiveDate As DateTime
End Class
如何检索每个RateType有多个EffectiveDate的子集_bankRates?
不幸的是,我发现所有类似的例子都在C#中,而且我喜欢LINQ翻译有点不那么简单,特别是当涉及到语法组时,例如查询以下
Dim ratesWithDuplicates = From rates In _bankRates
Group rates By rates.Key.RateType
Into grp()
Where grp.Count > 1
我收到错误:
在此上下文中无法访问方法'grp'的定义
答案 0 :(得分:2)
以下是您正在寻找的代码段
Dim ratesWithDuplicates =
From rates In _bankRates
Group rates By rates.Key.RateType Into Group
Where Group.Count() > 1
表达式/ keyword Group
表示集合。您可以使用name = Group
语法
Dim ratesWithDuplicates =
From rates In _bankRates
Group rates By rates.Key.RateType Into someName = Group
Where someName.Count() > 1