cancel
Showing results for 
Search instead for 
Did you mean: 

Adding unique records to a Member List

Jason
New Contributor II

Hello-

I have created a business rule that uses a buffer to bring back UD1 members that have a value against them, then they are added to a list like this:

myList.Add(api.Members.GetMember(DimType.UD1.Id, curUD1))

Later on in my code I do a sort Ascending, and return the results back to a cube view:

objMembers = (From member In myList Order By Member.Name Ascending Select Member).ToList()

I'm encountering a problem with duplicate values in the results.  This is because a small number of UD1 members have activity booked against them across more than one of the entities I am processing.

Are there any quick solutions to removes the duplicates in the add to list or sort steps?

The only thing I can think of would be to check if the value exists in the list before I add it, but that would require more coding.

Thanks

1 ACCEPTED SOLUTION

Jason
New Contributor II

I got this working, the fix was simple.  

On the sort line just add a Distinct()

The code becomes:

objMembers = (From member In myList Order By Member.Name Ascending Select Member).Distinct().ToList()

View solution in original post

1 REPLY 1

Jason
New Contributor II

I got this working, the fix was simple.  

On the sort line just add a Distinct()

The code becomes:

objMembers = (From member In myList Order By Member.Name Ascending Select Member).Distinct().ToList()

Please sign in! Jason