sql - linq where AND with multiple OR's -


I have a datatylet that I am trying to find different rows which on LINQ's set of columns Is different. The datatale contains the following column structure: name, department, change, emp, on call I am trying to find all the rows that have the same name and department, but where the change, empType or oncol may be different I have the following LINQ has tried but it only gives me the duplicate that exists. New in the empDataTable group in

  in DataRowView and {name = E.RO ["name"], section = E.RO ["department"], shift = e.RO ["change "], Select Employee Type = E.RO [" Empty Type "], Onol = E.RO [" On Call "]} in G (G.) & Gt; 1);  

Any help would be appreciated.

You need to exclude columns that you distinguish from the GROUP BY key Otherwise, LINQ will create a separate group for each combination, so the rows will be counted for the other 1 from the complete duplicate (i.e. all five column matching rows):

from in the DataRowView E in the empDataTable group and new {name = E.RO ["name"], in Dept = e.Row ["department"]} g (g.GroupBy (g = & gt; New {shift = E. rao ["shi Ft "], Employee Type = E.RO [[empType]], Oncol = E.RO [" On Call "]}). Calculate ()> 1) Choose G;

The internal group BY group by the remaining three columns if all three columns are the same for a {name, department} pair The group is ignored. Otherwise, the group is reported as a query result.


Comments