使用LINQ选择对象的不同属性

时间:2014-02-12 13:44:43

标签: linq select dictionary distinct

我如何改进此代码:

Dim count As Integer = 0
Dim myDictionary As Dictionary(Of Long, List(Of Proposal)) = list.GroupBy(Function(x) x.BankAccountId).ToDictionary(Function(g) g.Key, Function(a) a.ToList)

For Each bAccId As Long In myDictionary.Keys
    Dim currencies As Dictionary(Of String, List(Of Proposal)) = myDictionary(bAccId).GroupBy(Function(x) x.Currency).ToDictionary(Function(g) g.Key, Function(a) a.ToList)

    For Each c As String In currencies.Keys
        Dim execDates2 As Dictionary(Of Date, List(Of Proposal)) = currencies(c).GroupBy(Function(x) x.ExecutionTime).ToDictionary(Function(g) g.Key, Function(a) a.ToList)
        count += execDates2.Keys.Count
    Next
Next

0 个答案:

没有答案