Adds the distinct keyword to the selection of a column.
public SimpleQuery Distinct()
Type: SimpleQuery
A SimpleQuery
object containing a Distinct
clause
Please read the section on Counting to learn how to use Distinct
with Count
.
For example, to return a list of distinct OrderIds from OrderDetails, use the following command.
var albums = db.OrderDetails.All() .Select( db.OrderDetails.OrderId.Distinct());
Simple.Data sends the following SQL to the database when albums is evaluated.
select Distinct([dbo].[OrderDetails].[OrderId]) from [dbo].[OrderDetails]
For example, to return a list of distinct OrderIds and AlbumIds from OrderDetails, use the following command.
var albums = db.OrderDetails.All() .Select( db.OrderDetails.OrderId.Distinct(), db.OrderDetails.AlbumId);
Simple.Data sends the following SQL to the database when albums is evaluated.
select Distinct([dbo].[OrderDetails].[OrderId]), [dbo].[OrderDetails].[AlbumId] from [dbo].[OrderDetails]