在 Linq 查询中拆分字段

Split Field in a Linq Query

下面是一个字段名OULocationPath的内容。我需要解析 OU=location 但只解析“位置”。不是“OU=”。

CN=我的名字,OU=部门,OU=地点,OU=总地区,DC=公司,DC=org

下面是我用来填充网格的查询。我还没有添加上面的字段。

  Public Function GetLocationList() As List(Of Contact)
    GetLocationList = mContacts.FindAll(Function(x) x.Company.Contains("CompanyName") = True And x.WorkEmail = Nothing And x.WorkPhone <> "")
End Function

谢谢!

@Andrew Morton 和@NetMage, 我能够使用以下代码使解析工作:

 Public Function GetLocationList() As List(Of Contact)
    GetLocationList = Nothing
    Dim Answerset = mContacts.FindAll(Function(x) x.Company.Contains("CompanyName") = True AndAlso x.WorkEmail = Nothing AndAlso x.WorkPhone IsNot Nothing)
    Dim _GridLocations As New List(Of Contact)
    Dim _GridLocation As Contact
    _GridLocations.Clear()

    For Each l In Answerset
        _GridLocation = New Contact
        With _GridLocation
            .FullName = l.FullName
            .WorkPhone = l.WorkPhone
            .Extension = l.Extension

            Dim s As String = l.OULocationPath
            Dim sp As String() = s.Split(New [Char]() {","c, "="c})
            Dim first6 As String() = sp.ToList().GetRange(0, 6).ToArray()
            .OULocationPath= first6(5)
        End With
        _GridLocations.Add(_GridLocation)
    Next
    GetLocationList = _GridLocations
End Function