Select distinct rows from datatable in Linq?

If it's not a typed dataset, then you probably want to do something like this, using the Linq-to-DataSet extension methods: var distinctValues = dsValues.AsEnumerable() . Select(row => new { attribute1_name = row. Field("attribute1_name"), attribute2_name = row.

Field("attribute2_name") }) .Distinct() Make sure you have a using System. Data statement at the beginning of your code in order to enable the Linq-to-Dataset extension methods Hope this helps!

If it's not a typed dataset, then you probably want to do something like this, using the Linq-to-DataSet extension methods: var distinctValues = dsValues.AsEnumerable() . Select(row => new { attribute1_name = row. Field("attribute1_name"), attribute2_name = row.

Field("attribute2_name") }) .Distinct(); Make sure you have a using System. Data; statement at the beginning of your code in order to enable the Linq-to-Dataset extension methods. Hope this helps!

I used attribute1_name there I am getting duplicate records – James123 Jul 14 '10 at 2:56.

Like this: (Assuming a typed dataset) someTable. Select(r => new { r. Attribute1_name, r.

Attribute2_name }).Distinct().

– Justin Niessner Jul 14 '10 at 2:09 @Justin: Not for a typed dataset. Tables in typed datasets inherit TypedTableBase, which implements IEnumerable. – SLaks?

Jul 14 '10 at 2:10 please provide me ... how iterate them – James123 Jul 14 '10 at 2:16 @James: foreach(var pair in ...) – SLaks? Jul 14 '10 at 13:43.

Check this link stackoverflow.com/questions/3234341/get-... Or try this var distinctRows = (from DataRow dRow in dTable. Rows select new col1=dRow"dataColumn1",col2=dRow"dataColumn2"}).Distinct().

You missed a {. – SLaks? Jul 14 '10 at 13:42.

Data; statement at the beginning of your code in order to enable the Linq-to-Dataset extension methods. Hope this helps!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions