I have a data table like below. I need to find out the unique policy number for all users. in below example, A001 is common policy number for all the users in the table. Can someone help me how to write the query using LINQ or any other possible way?
you can get the unique policy numbers probably like this: dt1.AsEnumerable.Select(Function(r) r("Policy").ToString.Trim).Distinct
Then, you can use that in a For each, to loop over each unique Policy:
For each policy In dt1.AsEnumerable.Select(Function(r) r("Policy").ToString.Trim).Distinct
For each row In dt1.AsEnumerable.Where(Function(r) r("Policy").ToString.Trim=policy ).ToArray
<perform actions on each name>
So essentially, you loop through each unique policy, then using .Where() filter it to the unique policy to loop through each name of the unique policy. I hope that makes sense.