I have following DataTable
DataTable dt = new dataTable();
I have got this dataTable filled from some another method. It will have 50000 rows and 40 columns before executing following statements.
Number of rows and columns may vary. hence I have not defined specific set of columns to the dataTable.
I want to add two columns at the end (guid and addeddate) and want to add same value in all 50K rows for those 2 columns.
I have written simple foreach loop for this. Is there any way that I can do it Parallely?
I tried using Parallel.Foreach but didnt get any success.
//by this time my dt will have 50000 rows and 40 columns
dt.Columns.Add(new DataColumn("guid", typeof(string)));
dt.Columns.Add(new DataColumn("addeddate", typeof(DateTime)));
string sessionIDValue = Convert.ToString(Guid.NewGuid());
DateTime todayDt = DateTime.Today;
foreach (DataRow row in dt.Rows)
{
row["guid"] = sessionIDValue;
row["addeddate"] = todayDt;
}
DefaultValuefor the DataColumns you are adding? I wouldn't dare to predict how well this performs (if it even works). - Filburt