I have a data table that is filtered to remove duplicate rows based on the values presented in one column, this is done via LINQ. Here is the error message that is encountered when removing duplicates:
“Unable to cast object of type ‘System.Double’ to type ‘System.String’.”
The LINQ query:
DT.AsEnumerable().GroupBy(Function(r) r.Field(of String)(Column A value).toString).Select(Function(s) s.First()).CopyToDataTable
Note: I’m not using Filter DataTable activity because I’m not aware of a way for it to remove whole rows based on the value in a single column, up for suggestions if it’s possible
There is an error with the LINQ query when it encounters integers in the data table, but it’s expecting strings. Tracing back through the code and looking at values during execution it seems that all works fine when the first value in the required column (Column A in example below) is presented as a string:
Example data (all is ok)
But when the first value in the column (Column A in example below) is an integer I get the error stated above.
Example data (error occurs when removing duplicates later)
I need help making the LINQ query cast the column A value to a string.
Sorry for the long post, I tried to address as many questions as I could think of to save some time on follow ups. Any and all help, tips, tricks are appreciated, thank you!