Selaa lähdekoodia

2003-12-30 Gonzalo Paniagua Javier <[email protected]>

	* DbDataAdapter.cs: handle MissingShemaAction.AddWithKey, call
	AcceptChanges in Update when a CommandBuilder is used and
	correctly fill information about primary keys in FillSchema.
	Patch from Sergei Malinin ([email protected]).

svn path=/trunk/mcs/; revision=21553
Gonzalo Paniagua Javier 22 vuotta sitten
vanhempi
sitoutus
4207917675

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

@@ -1,3 +1,10 @@
+2003-12-30  Gonzalo Paniagua Javier <[email protected]>
+
+	* DbDataAdapter.cs: handle MissingShemaAction.AddWithKey, call
+	AcceptChanges in Update when a CommandBuilder is used and
+	correctly fill information about primary keys in FillSchema.
+	Patch from Sergei Malinin ([email protected]).
+
 2003-12-23  Tim Coleman <[email protected]>
 	* DbConnectionString.cs:
 		Some implementation

+ 5 - 4
mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs

@@ -362,6 +362,8 @@ namespace System.Data.Common {
 		
 		protected virtual int Fill (DataSet dataSet, int startRecord, int maxRecords, string srcTable, IDbCommand command, CommandBehavior behavior) 
 		{
+			if (MissingSchemaAction == MissingSchemaAction.AddWithKey)
+			    behavior |= CommandBehavior.KeyInfo;
 			CommandBehavior commandBehavior = behavior;
 			if (command.Connection.State == ConnectionState.Closed) {
 				command.Connection.Open ();
@@ -516,8 +518,7 @@ namespace System.Data.Common {
 				// generate DataSetColumnName from DataTableMapping, if any
 				string dsColumnName = realSourceColumnName;
 				DataTableMapping tableMapping = null;
-				if (schemaType == SchemaType.Mapped)
-					tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (TableMappings, table.TableName, table.TableName, MissingMappingAction); 
+				tableMapping = DataTableMappingCollection.GetTableMappingBySchemaAction (TableMappings, table.TableName, table.TableName, MissingMappingAction); 
 				if (tableMapping != null) 
 				{
 					
@@ -552,7 +553,7 @@ namespace System.Data.Common {
 				}
 				readerIndex++;
 			}
-			if (MissingSchemaAction == MissingSchemaAction.AddWithKey && primaryKey.Count > 0)
+			if (primaryKey.Count > 0)
 				table.PrimaryKey = (DataColumn[])(primaryKey.ToArray(typeof (DataColumn)));
 
 			return mapping;
@@ -697,7 +698,6 @@ namespace System.Data.Common {
 
 						parameter.Value = row [dsColumnName, rowVersion];
 					}
-					row.AcceptChanges ();
 				}
 
 				if (command.Connection.State == ConnectionState.Closed) 
@@ -711,6 +711,7 @@ namespace System.Data.Common {
 						throw new DBConcurrencyException("Concurrency violation: the " + commandName +"Command affected 0 records.");
 					updateCount += tmp;
 					OnRowUpdated (CreateRowUpdatedEvent (row, command, statementType, tableMapping));
+					row.AcceptChanges ();
 				}
 				catch (Exception e)
 				{