how dataset use in Parallel.ForEach
-
08 Maret 2012 8:43
Following code showing some errors
Parallel.ForEach<DataRow>(oDsData.Tables[0].Rows, dr =>
{
// code in here
});i need syntax for using dataset in parallel foreach
shijo
- Diedit oleh shijo thomas c 08 Maret 2012 8:53
Semua Balasan
-
08 Maret 2012 8:56
DataTable.Rowsreturns aDataRowCollectionwhich only implementsIEnumerable, notIEnumerable<DataRow>. Use theAsEnumerable()extension method onDataTable(fromDataTableExtensions) instead:Parallel.ForEach(dt.AsEnumerable(), drow =>code in here
{
...
...
});
shijo
- Diedit oleh shijo thomas c 08 Maret 2012 8:57
- Ditandai sebagai Jawaban oleh shijo thomas c 08 Maret 2012 11:49
-
08 Maret 2012 8:57
-
08 Maret 2012 10:23
Yes. It is possible. See the below code,
Parallel.ForEach<DataRow>(oDsData.Tables[0].Rows.OfType<DataRow>(), dr => { // code in here });
Other than this there is no option than to use AsEnumerable. I hope this helps.Please mark this post as answer if it solved your problem. Happy Programming!
- Ditandai sebagai Jawaban oleh shijo thomas c 08 Maret 2012 11:49
-
13 Maret 2012 13:39
there is any performance degradation using dataset to linq(oDsData.Tables[0].Rows.OfType<DataRow>()
shijo