How to use group by and if activities together with linq?

Hi,

Can you try the following expression?

dt = dt.AsEnumerable.GroupBy(Function(r) r("MailUID").ToString()).SelectMany(Function(g) g.Where(Function(r,i) r("Status").ToString.Trim<>"Success" OrElse (i=0 AndAlso g.All(Function(r2) r2("Status").ToString.Trim="Success")))).CopyToDataTable()

Sample220221113-2L.zip (2.9 KB)

Regards,

1 Like