Dim SearchResults = ( From a In EntityName Select a.Column1, a.Column2, a.Column3 ).Distinct()
However, if EntityName is a view, you may notice the Distinct statement might not work. You may find that your results contain duplicate rows. How can this be?
The Distinct capability is only available on columns that aren't set as "unique". And this makes sense, I suppose, because why would anyone want to do a Distinct on a column where duplicates are impossible?
But if your EntityName is a view, and one of the columns comes from a unique table column, then Entity Framework marks it as an "Entity Key" in the EDMX data model. Of course, if your view is joining tables, like they often do, you could certainly expect some duplicates in these key fields. This is exactly the case where a Distinct statement would not work for you.
The lesson here is to open up the EDMX data model, and set the Entity Key property of any non-unique columns in your view to False. Then Distinct should work properly.