使用lambda语法从vb.net中的匿名类型检索属性

时间:2013-11-21 15:32:08

标签: vb.net linq lambda linq-to-entities anonymous-types

我试图做这样的事情:

Dim list = (From c In value
                   Where Not c.IsMatched
                   Select c.City, c.State, c.Country).ToList()

        RadComboBoxSuggestedState.DataSource = list.Select(Function(x) x.city)

尝试从匿名类型获取city属性,但我收到此错误:

  

System.MissingMemberException未被用户代码处理     的HResult = -2146233070     Message =公共成员'选择'类型'List(Of VB $ AnonymousType_0(Of String,String,String))'未找到。     源= Microsoft.VisualBasic程序

任何帮助?

1 个答案:

答案 0 :(得分:0)

尝试选择新的匿名类型:

Dim list = (From c In value
            Where Not c.IsMatched
            Select New With {.City = c.City, .State = c.State, .Country = c.Country}