用于c#linq查询的Vb.net等效查询

时间:2012-04-16 12:29:56

标签: c# vb.net linq

任何人都可以为下面的C#linq查询提供vb.net等效查询

var res= from volunteer in dtavailableVolunteers 
    group volunteer by volunteer.Id into g
    let volunteerDates = g.Select(groupedElement=>groupedElement.date)
    where arr.All(date=>volunteerDates.Contains(date))
    select g.Key

我编写了下面的查询,但它抛出'重载解析失败,因为没有可访问的'select'可以用这些参数调用'Exception

 Dim dr As DataRow() = From item In dtavailableVolunteers.AsEnumerable() _ 
 Group item By item.VolunteerId Into g = Group
                          Let volunteerDates = g.[Select](Function(groupedElement) groupedElement.Field("SelectedDate")) _
                          Where SelectedDatesArray.All(Function([SelectedDate]) volunteerDates.Contains([SelectedDate])) Select g

1 个答案:

答案 0 :(得分:0)

我刚从online conversion tool转换它..我不知道它是否正确。请测试它是否有效......

Dim res = _
    Let volunteerDates = g.[Select](Function(groupedElement) groupedElement.[date]) _
    Where arr.All(Function([date]) volunteerDates.Contains([date]))