|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataRow[] merge problem .net 2.0I am currently migrating a few projects / solutions to .Net 2.0, and I have found out a problem merging an array of dataRows. On .net 1.1 a dataRow will be merged into a table on a dataSet with the same table name. Now on .net 2.0 creates a new table. This only happens when the tables belong to dataSets of different schema. Eg: DataSet X with table Y and DataSet Z with table Y. This only happens when merging DataRows not when mergin the whole DataTable. I have created a method to workaround this problem but as you can see this is far from ideal. public void MergeRowsOnDataTableWithSameName(DataRow[] rows, DataSet dataSet, LoadOption loadOption) { if (rows.Length > 0) { string tableName = rows[0].Table.TableName; if (!dataSet.Tables.Contains(tableName)) { dataSet.Merge(rows); } else { DataTable dataTable = dataSet.Tables[tableName]; for (int i = 0; i < rows.Length; i++) { dataTable.LoadDataRow(rows[i].ItemArray, loadOption); } } } else { throw new ArgumentException("There is no data on the array", "rows"); } } Can anybody let me know if this is a new design feature and if so the reasoning behind it?, if it is a bug will it be solved on the next service pack? Thanks Juan |
|||||||||||||||||||||||