Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27124

VS 2010 [RESOLVED] Trying to learn some LINQ. Not succeeding......

$
0
0
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)

Code:

Dim Groups As PrincipalSearchResult(Of Principal) = TryCast(Me.SelectedUser.GetGroups.Where(Function(g) g.Name.Contains("SYSTEM") = True), PrincipalSearchResult(Of Principal))

Viewing all articles
Browse latest Browse all 27124

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>