Compartilhar via


Cláusula Distinta (Visual Basic)

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

Distinct

Comentários

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.

Exemplo

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.

Dim customerOrders = From cust In customers, ord In orders
                     Where cust.CustomerID = ord.CustomerID
                     Select cust.CompanyName, ord.OrderDate
                     Distinct

Consulte também

Referência

A partir da cláusula (Visual Basic)

Cláusula Select (Visual Basic)

Clúasula Where (Visual Basic)

Conceitos

Introdução ao LINQ no Visual Basic

Outros recursos

Consultas(Visual Basic)