0

I have a table with multiple email addresses from one person - So EACH email address is listed several times in this table.

I would like to make it Distinct - so every email address is listed one.

My table has a relationship from the Customers table to the Customer Email address collection table

Customers.CustomerEmails.Where(Function(e) e.EmailId = EmailID).OrderBy(Function(o) o.CustomerId).Distinct()

I added a Distinct to the end of the statement but this didn't work. I have added Distinct after each method but that doesn't work either.

I then tried to add the order by at a different location in case this is causing some issues but again that didn't help either.

Does anyone know what I'm doing wrong here?

Computer
  • 2,149
  • 7
  • 34
  • 71
  • Take a look at http://stackoverflow.com/questions/2537823/distinct-by-property-of-class-by-linq where various alternatives are proposed. It is C#, but converting C# LINQ code to VB.NET is quite easy. – varocarbas Oct 16 '15 at 14:54
  • 1
    The CustomerEmail entities are different, so the distinct does return them all. You need to select only the emailaddress string and distinct on that... – Pleun Oct 17 '15 at 12:01
  • So i need to create a List of CustomerEmail and then Distinct on that? – Computer Oct 19 '15 at 10:36

0 Answers0