I thought I'd smarten up some my code a bit by trying to remove clumsy If/Then loops in place of LINQ Queries. Specifically, I'm trying to filter a list of groups from a PrincipalSearchResult. I just want the groups containing the word "SYSTEM"
However, with this LINQ query I get that age-old classic "object reference not set to an instance of an object" and I'm not sure why. I know what that error means, of course, I just don't understand why it would be happening here (other than my noob-level knowledge of LINQ that is)
However, with this LINQ query I get that age-old classic "object reference not set to an instance of an object" and I'm not sure why. I know what that error means, of course, I just don't understand why it would be happening here (other than my noob-level knowledge of LINQ that is)
Code:
Dim Groups As PrincipalSearchResult(Of Principal) = TryCast(Me.SelectedUser.GetGroups.Where(Function(g) g.Name.Contains("SYSTEM") = True), PrincipalSearchResult(Of Principal))