Retrieving Data from DataView C# takes too long
I have a DataTable named 'dtStocksCriteria'; each cell in it should turn into a process function. So I should traverse all rows and columns.
For this purpose I have Parallel loop on rows. Then I select the Row with this Code:
DataView dv = new DataView(dtStocksCriteria); dv.RowFilter = "xStockCode_FK = " + stock.Code;
After that in an Inner Parallel loop I should retrieve each column value with something like this code.
val = (double)dv["column name"];
This Assignment take about 0.5 seconds which is too long for me. I want to reduce that to approximately 1 millisecond.
I have 398 rows and 110 columns in mt data table, in case that helps.
Does anyone have any ideas?
In C# working with DataView or DataRow or DataTable takes time. BUT If you use DataRow[int index] to retrive a cell value it should takes less time than using DataRow[string ColumnName] .
When I use 'index' instead of 'ColumnName' it makes my code faster.
It is still slow because I have too much columns. So the best solution is to reduce the columns count first.