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

◆ BuildCache()

void System.Data.Common.DbCommandBuilder.BuildCache ( bool closeConnection,
DataRow dataRow,
bool useColumnsForParameterNames )
inlineprivate

Definition at line 479 of file DbCommandBuilder.cs.

480 {
481 if (_dbSchemaTable != null && (!useColumnsForParameterNames || _parameterNames != null))
482 {
483 return;
484 }
485 DataTable dataTable = null;
486 DbCommand selectCommand = GetSelectCommand();
487 DbConnection connection = selectCommand.Connection;
488 if (connection == null)
489 {
490 throw ADP.MissingSourceCommandConnection();
491 }
492 try
493 {
494 if ((ConnectionState.Open & connection.State) == 0)
495 {
496 connection.Open();
497 }
498 else
499 {
500 closeConnection = false;
501 }
502 if (useColumnsForParameterNames)
503 {
504 DataTable schema = connection.GetSchema(DbMetaDataCollectionNames.DataSourceInformation);
505 if (schema.Rows.Count == 1)
506 {
507 _parameterNamePattern = schema.Rows[0][DbMetaDataColumnNames.ParameterNamePattern] as string;
508 _parameterMarkerFormat = schema.Rows[0][DbMetaDataColumnNames.ParameterMarkerFormat] as string;
509 object obj = schema.Rows[0][DbMetaDataColumnNames.ParameterNameMaxLength];
510 _parameterNameMaxLength = ((obj is int) ? ((int)obj) : 0);
512 {
513 useColumnsForParameterNames = false;
514 }
515 }
516 else
517 {
518 useColumnsForParameterNames = false;
519 }
520 }
521 dataTable = GetSchemaTable(selectCommand);
522 }
523 finally
524 {
525 if (closeConnection)
526 {
527 connection.Close();
528 }
529 }
530 if (dataTable == null)
531 {
532 throw ADP.DynamicSQLNoTableInfo();
533 }
534 BuildInformation(dataTable);
535 _dbSchemaTable = dataTable;
536 DbSchemaRow[] dbSchemaRows = _dbSchemaRows;
537 string[] array = new string[dbSchemaRows.Length];
538 for (int i = 0; i < dbSchemaRows.Length; i++)
539 {
540 DbSchemaRow dbSchemaRow = dbSchemaRows[i];
541 if (dbSchemaRow != null)
542 {
543 array[i] = dbSchemaRow.ColumnName;
544 }
545 }
547 if (useColumnsForParameterNames)
548 {
549 _parameterNames = new ParameterNames(this, dbSchemaRows);
550 }
551 ADP.BuildSchemaTableInfoTableNames(array);
552 }
void BuildInformation(DataTable schemaTable)
virtual ? DataTable GetSchemaTable(DbCommand sourceCommand)

References System.Data.Common.DbCommandBuilder._dbSchemaRows, System.Data.Common.DbCommandBuilder._dbSchemaTable, System.Data.Common.DbCommandBuilder._parameterMarkerFormat, System.Data.Common.DbCommandBuilder._parameterNameMaxLength, System.Data.Common.DbCommandBuilder._parameterNamePattern, System.Data.Common.DbCommandBuilder._parameterNames, System.Data.Common.DbCommandBuilder._sourceColumnNames, System.array, System.Data.Common.DbCommandBuilder.BuildInformation(), System.Data.Common.ADP.BuildSchemaTableInfoTableNames(), System.Data.Common.DbConnection.Close(), System.Data.Common.DbSchemaRow.ColumnName, System.Data.Common.DbCommand.Connection, System.Data.DataRowCollection.Count, System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation, System.Data.Common.ADP.DynamicSQLNoTableInfo(), System.Data.Common.DbConnection.GetSchema(), System.Data.Common.DbCommandBuilder.GetSchemaTable(), System.Data.Common.DbCommandBuilder.GetSelectCommand(), System.Text.RegularExpressions.i, System.Data.Common.ADP.MissingSourceCommandConnection(), System.obj, System.Data.Common.DbConnection.Open(), System.Data.Common.DbMetaDataColumnNames.ParameterMarkerFormat, System.Data.Common.DbMetaDataColumnNames.ParameterNameMaxLength, System.Data.Common.DbMetaDataColumnNames.ParameterNamePattern, System.Data.DataTable.Rows, and System.Data.Common.DbConnection.State.

Referenced by System.Data.Common.DbCommandBuilder.GetDeleteCommand(), System.Data.Common.DbCommandBuilder.GetInsertCommand(), System.Data.Common.DbCommandBuilder.GetUpdateCommand(), and System.Data.Common.DbCommandBuilder.RowUpdatingHandlerBuilder().