Web developers use optional LINQ Distinct clause when they want to receive a list of unique items. The Distinct clause ignores duplicate query results and can be applied to duplicate values for all return fields specified by the Select clause. If no Select clause is specified, the Distinct clause is applied to the range variable for the query identified in the From clause. If the range variable is not an immutable type, the query will only ignore a query result if all members of the type match an existing query result.

The following query expression joins a list of clients and a list of client orders. The Distinct clause is included to return a list of unique client names and order products.

 

Dim clientOrders = From client In clients, ord In orders _

Where client.ClientID = ord.ClientID _

Select client.Company, ord.ProductName _

Distinct