how dataset use in Parallel.ForEach
-
8 martie 2012 08: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
- Editat de shijo thomas c 8 martie 2012 08:53
Toate mesajele
-
8 martie 2012 08:56
DataTable.Rowsreturns aDataRowCollectionwhich only implementsIEnumerable, notIEnumerable<DataRow>. Use theAsEnumerable()extension method onDataTable(fromDataTableExtensions) instead:Parallel.ForEach(dt.AsEnumerable(), drow =>code in here
{
...
...
});
shijo
- Editat de shijo thomas c 8 martie 2012 08:57
- Marcat ca răspuns de shijo thomas c 8 martie 2012 11:49
-
8 martie 2012 08:57
-
8 martie 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!
- Marcat ca răspuns de shijo thomas c 8 martie 2012 11:49
-
13 martie 2012 13:39
there is any performance degradation using dataset to linq(oDsData.Tables[0].Rows.OfType<DataRow>()
shijo