This project is read-only.

How to Use Distinct

Nov 9, 2009 at 3:43 PM

Anybody knows how to use DISTINCT in a collection..

Thanks 

Nov 9, 2009 at 8:45 PM

Use the GetDistinct static method. The first parameter is the field you are checking for distinctness and the second paramter is the where clause. The statement below will find all distinct first names for customers where the customer id is less than 100.

IEnumerable<string> idList = CustomerCollection.GetDistinct(x => x.FirstName, x => x.CustomerId < 100);

If you are trying to find distinct values in a loaded, in-memory collection, just use standard LINQ.

Nov 9, 2009 at 9:12 PM

can u give sample on how to do it? do i have still use the runselect?

Nov 9, 2009 at 10:04 PM

That last post was an example of how to use it. There is a GetDistinct static method on all collections. You can use it to select distinct values from a database table based on a where clause. Maybe we are talking about different things. What are you trying to accomplish?

Dec 4, 2009 at 3:11 AM

This is an aggregate function. There is a training video on this subject on YouTube. http://www.youtube.com/watch?v=UGXImHM3ksg