Forum Discussion

Kenn's avatar
Kenn
New Contributor
3 months ago
Solved

Removing Duplicates from a Member Filter

Hi All,  I have the following use case whereby in my parameter, I have a member list of C#Local,C#USD,C#JPY,C#|WFText2| whereby WFText2 will be currencies/consolidation members eg. CNY,EUR,SGD,USD...
  • sameburn's avatar
    3 months ago

    Hi Kenn​

    If you are working with a Member List you can use something like this Linq syntax (see vb example below).

    ** This assumes that we are using object Member in our list and therefore we can access Name property

    Dim List(of Member) distinctByName = yourMemberList _
        .GroupBy(Function(p) p.Name) _
        .Select(Function(g) g.First()) _
        .ToList()

    This will get the First instance of duplicate e.g C#Local in your example. If you want Last, simply change syntax to be .Last() instead 

    Hope this helps

    Sam