merging the Mainsoft branch to the trunk
[mono.git] / mcs / class / System.Data / System.Data / DataRowCollection.cs
index 77da26feaecaab6a3bb8f39b87cb5ca9197f6812..a3cbb45804e42ff47a371aa07769f1472cb1c2ae 100644 (file)
@@ -157,6 +157,10 @@ namespace System.Data
                                        }
                                }
                        }
+                        // Remove from indexes
+                        for (int i = 0; i < this.Count; i++)
+                                this.table.DeleteRowFromIndexes (this [i]);
+
                        List.Clear ();
                }
 
@@ -184,17 +188,17 @@ namespace System.Data
                public DataRow Find (object key) 
                {
                        return Find(new object[]{key});
-               }
+                }
 
                /// <summary>
                /// Gets the row containing the specified primary key values.
                /// </summary>
-               public DataRow Find (object[] keys) 
+               public DataRow Find (object[] keys)
                {
                        if (table.PrimaryKey.Length == 0)
                                throw new MissingPrimaryKeyException ("Table doesn't have a primary key.");
 
-                        if (keys == null)
+                       if (keys == null)
                                throw new ArgumentException ("Expecting " + table.PrimaryKey.Length +" value(s) for the key being indexed, but received 0 value(s).");
                                                                                                     
                        Index index = table.GetIndex(table.PrimaryKey,null,DataViewRowState.None,null,false);
@@ -329,6 +333,9 @@ namespace System.Data
                        row.CheckNullConstraints();
 
                        int newRecord = (row.Proposed >= 0) ? row.Proposed : row.Current;
+                       if (newRecord < 0)
+                               return;
+
                        foreach(Index index in table.Indexes) {
                                index.Update(row,newRecord);
                        }