Browse Source

2006-03-23 Senganal T <[email protected]>

	* Test/System.Data/DataTableTest2.cs :
		- Ensure duplicate rows are merged when using LoadDataRow
	* Test/System.Data/DataRowCollectionTest2.cs :
		- Ensure row can be searched using Find (), when added using LoadDataRow
	* System.Data/DataTable.cs : 
		- LoadDataRow : Add the row to the indexes, when loading a new row.


svn path=/trunk/mcs/; revision=58356
Senganal T 20 years ago
parent
commit
1f5bb728db

+ 5 - 0
mcs/class/System.Data/System.Data/ChangeLog

@@ -1,3 +1,8 @@
+2006-03-23  Senganal T  <[email protected]>
+
+	* DataTable.cs : 
+		- LoadDataRow : Add the row to the indexes, when loading a new row.
+
 2006-03-22  Senganal T  <[email protected]>
 
 	* DataTable.cs :

+ 1 - 1
mcs/class/System.Data/System.Data/DataTable.cs

@@ -1203,6 +1203,7 @@ namespace System.Data {
 				if (existingRecord < 0) {
 					row = NewRowFromBuilder (RowBuilder);
 					row.Proposed = newRecord;
+					AddRowToIndexes (row);
 					Rows.AddInternal(row);
 				}
 				else {
@@ -1210,7 +1211,6 @@ namespace System.Data {
 					row.BeginEdit();
 					row.ImportRecord(newRecord);
 					row.EndEdit();
-					
 				}
 				
 				if (fAcceptChanges)

+ 7 - 0
mcs/class/System.Data/Test/System.Data/ChangeLog

@@ -1,3 +1,10 @@
+2006-03-23  Senganal T <[email protected]>
+
+	* DataTableTest2.cs :
+		- Ensure duplicate rows are merged when using LoadDataRow
+	* DataRowCollectionTest2.cs :
+		- Ensure row can be searched using Find (), when added using LoadDataRow
+
 2006-03-22  Senganal T <[email protected]>
 
 	* DataColumnTest2.cs :

+ 0 - 1
mcs/class/System.Data/Test/System.Data/DataRowCollectionTest2.cs

@@ -225,7 +225,6 @@ namespace MonoTests.System.Data
 		}
 
 		[Test]
-		[NUnit.Framework.Category ("NotWorking")]
 		public void FindByKey_DuringDataLoad ()
 		{
 			DataTable table = new DataTable ();

+ 19 - 0
mcs/class/System.Data/Test/System.Data/DataTableTest2.cs

@@ -422,6 +422,25 @@ namespace MonoTests_System.Data
 			}
 		}
 
+		[Test]
+		public void EndLoadData_MergeDuplcateValues ()
+		{
+			DataTable table = new DataTable ();
+			table.Columns.Add ("col1", typeof (int));
+			table.Columns.Add ("col2", typeof (int));
+
+			table.PrimaryKey = new DataColumn[] {table.Columns [0]};
+
+			table.BeginLoadData ();
+			table.LoadDataRow (new object[] {1 , 1}, false);
+			table.LoadDataRow (new object[] {1 , 10}, false);
+			table.LoadDataRow (new object[] {1 , 100}, false);
+			table.EndLoadData ();
+
+			Assert.AreEqual (1, table.Rows.Count, "#1");
+			Assert.AreEqual (100, table.Rows [0][1], "#2");
+		}
+
 		[Test] public void GetChanges()
 		{
 			DataTable dt1,dt2 = DataProvider.CreateParentDataTable();