几天前,我通过这个线程问了一个几乎与此相同的问题,并得到了很棒的回复——对我来说最大的教训(除了答案本身)是为我的持有数据创建一个自定义对象。那么,既然已经这样做了,我可以请各位专家向我展示最有效的 Linq 语句来满足我的要求吗?
我的场景如下:
假设我有以下控股类:
Public Class Class_Info
Public Property Teacher As String
Public Property Name As String
Public Property Sex As String
End Class
然后,假设我在另一个模块中有以下内容:
Dim X as new list(of Class_Info)
列表中包含以下元素:
Element.Teacher: Element.Sex: Element.Name:
Teacher 1 Male Whatever Name 1
Teacher 2 Female Whatever Name 2
Teacher 1 Female Whatever Name 3
Teacher 1 Female Whatever Name 4
Teacher 2 Male Whatever Name 5
Teacher 3 Male Whatever Name 6
Teacher 3 Female Whatever Name 7
Teacher 1 Male Whatever Name 8
Teacher 1 Female Whatever Name 9
Teacher 2 Male Whatever Name 10
现在,假设我想使用以下值创建以下结构:
Dim dictTeacherSexName as New Dictionary(Of String, Dictionary(Of String, List(of String)))
Dict1_Key: Dict1_Value / Dict2_Key: Dict2_Value:
Teacher 1 Male Whatever Name 1
Whatever Name 8
Female Whatever Name 3
Whatever Name 4
Whatever Name 9
Teacher 2 ...
我怎样才能以最有效的方式通过 Linq 创建它?
谢谢!!!