Hello Guys,
I am trying to group a datatable based on two columns a and b.
for example
col a,col b
a,b
a,b
c,d
e,d
c,d
f,g
so here I want output is
col a,col b
a,b
a,b
f,g
but I am getting output as
col a,col b
a,b
a,b
c,d
c,d
which shouldn’t be the output since b column has same value “d” but distinct values in “d” value group
linq query I am using is
(From d In dt_Master.AsEnumerable Where (Not String.IsNullOrEmpty(“a”).ToString))
Group d By k1= d(“a”).toString.trim,k2 =d(“b”).ToString.Trim.Contains(row(“unqiue value list in b column”).ToString) Into grp=Group
Let ra = New Object(){k1,k2}
Where grp.Count > 0
Where grp.Select(Function (x) x(“Ship-to party’s purchase order no.”).toString.Trim).Distinct().Count <= 1
Select dt_Result.Rows.Add(ra)).CopyToDatable
so conclusion is I want dt whose b column is same in a group and also a column’s all value should be same . if only one row is available than it its fine but if more than one row is present a column values should be thought the group