Search code examples
vb.netlinq

Linq to find a specific item by guid in a list and return the next 10 next to it


Please how can I find an item in a list and then take the next 10 items starting from my selected item.

    Dim AllGirls = db.GetAllGirlsClosestToSelected().ToList

    Dim SelectedGirls = AllGirls.where(function(i) i.girlID = 
    SelectedGirlID).take(10)

So if user selects a girl, I am trying to bring back the next 10 grils in the list next to selected girl


Solution

  • Here's a way to do it in C#

    AllGirls.SkipWhile(g => (g.girlID != SelectedGirlID))
            .Take(10);
    

    I'm definitely not a VB expert, but it should translate to:

    AllGirls.SkipWhile(function(g) g.girlID <> SelectedGirlID))
            .Take(10)