Itz.Irshad
Itz.Irshad

Reputation: 1024

Retrieve Distinct Records in LINQ Query

I have a DataSet and Select few records from Table in DataSet using following query:

EnumerableRowCollection<DataRow> GenresQuery = from genre in Books.AsEnumerable() where genre.Field<string>("genre") == strGenresSelectionParameter select genre;

It is working fine but, I want to select distinct records. How it can be done ?

Upvotes: 0

Views: 1309

Answers (1)

Habib
Habib

Reputation: 223237

Use Distinct

IEnumerable<DataRow> GenresQuery = (from genre in Books.AsEnumerable()
                                    where genre.Field<string>("genre") == strGenresSelectionParameter 
                                    select genre).Distinct();

Upvotes: 1

Related Questions