Posted on: 11/10/2012 12:55:05 AM | Views : 416

I have a situation where I'm updating a "working" Data Table with its equivalent from the DB.  Here's some partial code:
foreach (DataRow dbRow in dbTaskList.Rows) { int taskID = (int)dbRow["TaskID"]; if (Common.GetDataTableRow(TaskList, "TaskID", taskID) == null) { DataRow[] drOneRow = dbTaskList.Select("TaskID = " + taskID); DataTable dtOneRow = drOneRow.CopyToDataTable<DataRow>(); TaskList.Merge(dtOneRow);
Please focus in on the last 3 lines.  Simply put, this does work to add one Row from 'dbTaskList' into 'TaskList'.  There is indeed the older way to accomplish this via the "NewRow()" statement and then copying one value at a time over.  However, I find LINQ much more elegant and readable to accomplish the same thing.
BUT it does seem rather silly to me that first I have to create a DataRow Array, then I have to convert that into a ...

Go to the complete details ...