Permalink
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (53 sloc) 2.15 KB
title ms.date ms.prod ms.reviewer ms.suite ms.technology ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author translation.priority.ht
Distinct Clause (Visual Basic)
2015-07-20
.net
devlang-visual-basic
article
vb.QueryDistinct
VB
Distinct clause
Distinct statement
queries [Visual Basic], Distinct
86f42614-0d8f-4ffc-b888-ce8a37a8d36a
15
dotnet-bot
dotnetcontent
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

Distinct Clause (Visual Basic)

Restricts the values of the current range variable to eliminate duplicate values in subsequent query clauses.

Syntax

Distinct  

Remarks

You can use the Distinct clause to return a list of unique items. The Distinct clause causes the query to ignore duplicate query results. The Distinct clause applies 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.

Example

The following query expression joins a list of customers and a list of customer orders. The Distinct clause is included to return a list of unique customer names and order dates.

[!code-vbVbSimpleQuerySamples#20]

See Also

Introduction to LINQ in Visual Basic
Queries
From Clause
Select Clause
Where Clause