I am attempting to write a Linq to SQL query that returns all rows in a DataTable where a columns value (TxnNumber) is not unique. So far, I have the Linq to SQL below where dt is the DataTable that contains the field TxnNumber. I think that I am pretty close but, intellisense is complaining about the CONTAINS clause. I have tried specifying that I only want to return the TxnNumber field in the sub-select but, it will not compile. Can anyone see what I am doing wrong?
dt.AsEnumerable().Where(u => u.TxnNumber.Contains (dt.AsEnumerable().GroupBy(t => t.TxnNumber).Count() > 1));
Try this