I have merged DataTable that consist duplicates in both columns.
DataTable structure: "Worknumber Username"
1234 John
1235 Mike
1235 Mike
1236 Donald
1236 Jack
I need to catch
1236 Donald
1236 Jack
and preferably output it in format
1236 Donald Jack
I have been trying to create Linq query for this purpose for some time now (quite long), but I can't figure out the right way.
Here is what I have so far. This works, I just tested that column names are correct with dataRow.Field<string>("WORKNUMBER"):
public static DataTable ProjectsInLiinos = new DataTable();
...
MainProcess.MergedTable();
foreach (DataRow dataRow in MainProcess.ProjectsInLiinos.Rows)
{
Console.WriteLine(dataRow.Field<string>("WORKNUMBER") + dataRow.Field<string>("USERNAME"));
}
Here is Linq query:
var queryCustomers = from data in MainProcess.ProjectsInLiinos.AsEnumerable()
where data.Field<string>("WORKNUMBER").Count() > 1 && data.Field<string>("USERNAME").Count() < 1
select data;
It does not produce anything. I can't figure out how I can make statement where first column duplicates are compared to second column duplicates?
Otherwise I could have grouped dataRow.Field<string>("WORKNUMBER") + dataRow.Field<string>("USERNAME") and then check list for duplicates, but it will produce then:
1235Mike
1235Mike
and in reverse
1234John
1236Donald
1236Jack