Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ UpdateBatchExecute()

void System.Data.Common.DbDataAdapter.UpdateBatchExecute ( BatchCommandInfo[] batchCommands,
int commandCount,
RowUpdatedEventArgs rowUpdatedEvent )
inlineprivate

Definition at line 1216 of file DbDataAdapter.cs.

1217 {
1218 try
1219 {
1221 rowUpdatedEvent.AdapterInit(recordsAffected);
1222 }
1223 catch (DbException ex)
1224 {
1225 ADP.TraceExceptionForCapture(ex);
1226 rowUpdatedEvent.Errors = ex;
1227 rowUpdatedEvent.Status = UpdateStatus.ErrorsOccurred;
1228 }
1229 MissingMappingAction updateMappingAction = UpdateMappingAction;
1230 MissingSchemaAction updateSchemaAction = UpdateSchemaAction;
1231 int num = 0;
1232 bool flag = false;
1233 List<DataRow> list = null;
1234 for (int i = 0; i < commandCount; i++)
1235 {
1236 BatchCommandInfo batchCommandInfo = batchCommands[i];
1237 StatementType statementType = batchCommandInfo._statementType;
1238 if (GetBatchedRecordsAffected(batchCommandInfo._commandIdentifier, out int recordsAffected2, out batchCommands[i]._errors))
1239 {
1240 batchCommands[i]._recordsAffected = recordsAffected2;
1241 }
1242 if (batchCommands[i]._errors != null || !batchCommands[i]._recordsAffected.HasValue)
1243 {
1244 continue;
1245 }
1246 if (StatementType.Update == statementType || StatementType.Delete == statementType)
1247 {
1248 num++;
1249 if (recordsAffected2 == 0)
1250 {
1251 if (list == null)
1252 {
1253 list = new List<DataRow>();
1254 }
1255 batchCommands[i]._errors = ADP.UpdateConcurrencyViolation(batchCommands[i]._statementType, 0, 1, new DataRow[1] { rowUpdatedEvent.Rows[i] });
1256 flag = true;
1257 list.Add(rowUpdatedEvent.Rows[i]);
1258 }
1259 }
1260 if ((StatementType.Insert == statementType || StatementType.Update == statementType) && (UpdateRowSource.OutputParameters & batchCommandInfo._updatedRowSource) != 0 && recordsAffected2 != 0)
1261 {
1262 if (StatementType.Insert == statementType)
1263 {
1264 rowUpdatedEvent.Rows[i].AcceptChanges();
1265 }
1266 for (int j = 0; j < batchCommandInfo._parameterCount; j++)
1267 {
1268 IDataParameter batchedParameter = GetBatchedParameter(batchCommandInfo._commandIdentifier, j);
1270 }
1271 }
1272 }
1273 if (rowUpdatedEvent.Errors == null && rowUpdatedEvent.Status == UpdateStatus.Continue && 0 < num && (rowUpdatedEvent.RecordsAffected == 0 || flag))
1274 {
1275 DataRow[] array = ((list != null) ? list.ToArray() : rowUpdatedEvent.Rows);
1276 rowUpdatedEvent.Errors = ADP.UpdateConcurrencyViolation(StatementType.Batch, commandCount - array.Length, commandCount, array);
1277 rowUpdatedEvent.Status = UpdateStatus.ErrorsOccurred;
1278 }
1279 }
virtual IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex)
MissingMappingAction UpdateMappingAction
virtual bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out Exception? error)
MissingSchemaAction UpdateSchemaAction
void ParameterOutput(IDataParameter parameter, DataRow row, DataTableMapping mappings, MissingMappingAction missingMapping, MissingSchemaAction missingSchema)

References System.array, System.Data.Common.DbDataAdapter.ExecuteBatch(), System.Data.Common.DbDataAdapter.GetBatchedParameter(), System.Data.Common.DbDataAdapter.GetBatchedRecordsAffected(), System.list, System.Data.Common.DbDataAdapter.ParameterOutput(), System.Data.Common.ADP.TraceExceptionForCapture(), System.Data.Common.ADP.UpdateConcurrencyViolation(), System.Data.Common.DbDataAdapter.UpdateMappingAction, and System.Data.Common.DbDataAdapter.UpdateSchemaAction.

Referenced by System.Data.Common.DbDataAdapter.Update().