public int Update(DataSet dataSet, string srcTable)
{
long logScopeId = DataCommonEventSource.Log.EnterScope("<comm.DbDataAdapter.Update|API> {0}, dataSet, srcTable='{1}'", ObjectID, srcTable);
try
{
if (null == dataSet)
{
throw ADP.UpdateRequiresNonNullDataSet(nameof(dataSet));
}
if (string.IsNullOrEmpty(srcTable))
{
throw ADP.UpdateRequiresSourceTableName(nameof(srcTable));
}
int rowsAffected = 0;
System.Data.MissingMappingAction missingMapping = UpdateMappingAction;
DataTableMapping tableMapping = GetTableMappingBySchemaAction(srcTable, srcTable, UpdateMappingAction);
Debug.Assert(null != tableMapping, "null TableMapping when MissingMappingAction.Error");
// the ad-hoc scenario of no dataTable just returns
// ad-hoc scenario is defined as MissingSchemaAction.Add or MissingSchemaAction.Ignore
System.Data.MissingSchemaAction schemaAction = UpdateSchemaAction;
DataTable dataTable = tableMapping.GetDataTableBySchemaAction(dataSet, schemaAction);
if (null != dataTable)
{
rowsAffected = UpdateFromDataTable(dataTable, tableMapping);
}
else if (!HasTableMappings() || (-1 == TableMappings.IndexOf(tableMapping)))
{
//throw error since the user didn't explicitly map this tableName to Ignore.
throw ADP.UpdateRequiresSourceTable(srcTable);
}
return rowsAffected;
}
finally
{
DataCommonEventSource.Log.ExitScope(logScopeId);
}
}