Many times, we face a challenge to get unique rows from a CAML query. The problem is CAML query does not have any feature to get the distinct rows. Luckily the Data View has a method to return a Table with distinct rows.
DataView.ToTable(Bool isDistinct, string columnName);
This will return a table with distinct values based on the column name given in the method.
Below is an example how to use this along with the CAML query
query.Query = strQuery;
itemColl = lst.GetItems(query);
dtInOut = itemColl.GetDataTable();
dvInOut = new DataView(dtInOut);
dvInOut.Sort = “Token_x0020_Number Asc”;
dtInOut = dvInOut.ToTable(true, “Token_x0020_Number”);
Here dvInOut.ToTable method will give values from the list with distinct Token_x0020_Number values.