[RESOLVED] Linq Query Question
Hey, guys. So I'm still learning LINQ here, and am having an issue with what should be an easy query.
Basically, my query is this: I want all of the characters that are of a membership level in a given area that is of admin or above.
This is what I have so far:
Code:
Dim L As List(Of Character) = (From C In MasterCharacterList.Characters.Values _
Where Me.Item(C.CharID).DreamLevel.ContainsValue( _
(From L In _Levels Where L.Value.Admin Or L.Value.BotMaster Select L.Value.MemberLevel).ToList.ForEach) Select C)
Me, in this case, is the members collection.
So far, I can't get the query to turn into a list (hence no .tolist at the end.) I know there's something wrong here, but I'm not sure what.
Re: [RESOLVED] Linq Query Question
I think I got what you're looking for, you're trying to compare one list vs. another list and if ANY items from list 2 are found in list one, then flag that character?
How about using "Intersect" to get the items that appear on both lists:
Code:
Dim Le As List(Of Integer) = (From L In _Levels _
Where L.Value.Admin Or L.Value.BotMaster _
Select L.Value.MemberLevel).ToList
Dim Lc As List(Of Character) = (From C As Character In MasterCharacterList.Characters.Values _
Where Me.item(C.CharID).DreamLevel.Intersect(Le) _
Select C).ToList
Re: [RESOLVED] Linq Query Question
Intersect is expecting a KVP(of string, integer), but I'm not sure how to get that when the key for_Levels in an integer.