42 _count = schemaRows.Length;
46 for (
int i = 0;
i < schemaRows.Length;
i++)
49 if (dbSchemaRow ==
null)
57 if (
text.Contains(
' '))
70 for (
int j = 0; j < schemaRows.Length; j++)
155 for (
int j =
i + 1; j <
_count; j++)
176 if (dbSchemaRow !=
null && dbSchemaRow.
AllowDBNull)
187 return _dbCommandBuilder.ParameterNameMaxLength - num;
193 string parameterName;
209 return parameterName;
279 if ((uint)(
value - 1) <= 2u)
301 if ((uint)(
value - 1) <= 1u)
316 if (catalogSeparator ==
null || 0 >= catalogSeparator.Length)
320 return catalogSeparator;
390 if (quoteSuffix ==
null)
413 if (schemaSeparator ==
null || 0 >= schemaSeparator.Length)
417 return schemaSeparator;
430 [DefaultValue(
false)]
479 private void BuildCache(
bool closeConnection,
DataRow dataRow,
bool useColumnsForParameterNames)
488 if (connection ==
null)
500 closeConnection =
false;
502 if (useColumnsForParameterNames)
513 useColumnsForParameterNames =
false;
518 useColumnsForParameterNames =
false;
530 if (dataTable ==
null)
537 string[]
array =
new string[dbSchemaRows.Length];
538 for (
int i = 0;
i < dbSchemaRows.Length;
i++)
541 if (dbSchemaRow !=
null)
547 if (useColumnsForParameterNames)
563 if (sortedSchemaRows ==
null || sortedSchemaRows.Length == 0)
567 string text =
string.Empty;
568 string text2 =
string.Empty;
569 string text3 =
string.Empty;
571 for (
int i = 0;
i < sortedSchemaRows.Length;
i++)
575 if (baseTableName ==
null || baseTableName.Length == 0)
577 sortedSchemaRows[
i] =
null;
585 text5 =
string.Empty;
589 text6 =
string.Empty;
593 text7 =
string.Empty;
600 text4 = baseTableName;
607 if (
text.Length == 0)
611 if (text2.Length == 0)
616 if (text3.Length == 0)
622 if (text4 ==
null || text4.Length == 0)
631 if (!
string.IsNullOrEmpty(quotePrefix) && -1 != text4.IndexOf(quotePrefix,
StringComparison.Ordinal))
635 if (!
string.IsNullOrEmpty(quoteSuffix) && -1 != text4.IndexOf(quoteSuffix,
StringComparison.Ordinal))
645 stringBuilder.
Append(catalogSeparator);
650 stringBuilder.
Append(catalogSeparator);
656 stringBuilder.
Append(schemaSeparator);
663 stringBuilder.
Append(catalogSeparator);
668 stringBuilder.
Append(catalogSeparator);
690 int parameterCount = 0;
691 stringBuilder.
Append(
"DELETE FROM ");
693 parameterCount =
BuildWhereClause(mappings, dataRow, stringBuilder, dbCommand, parameterCount, isUpdate:
false);
694 dbCommand.CommandText = stringBuilder.
ToString();
706 stringBuilder.
Append(
"INSERT INTO ");
709 string[]
array =
new string[dbSchemaRows.Length];
710 for (
int i = 0;
i < dbSchemaRows.Length;
i++)
719 if (mappings !=
null && dataRow !=
null)
740 stringBuilder.
Append(
" DEFAULT VALUES");
744 stringBuilder.
Append(
')');
745 stringBuilder.
Append(
" VALUES ");
746 stringBuilder.
Append(
'(');
748 for (
int j = 1; j < num; j++)
750 stringBuilder.
Append(
", ");
753 stringBuilder.
Append(
')');
755 dbCommand.CommandText = stringBuilder.
ToString();
765 string value =
" SET ";
767 stringBuilder.
Append(
"UPDATE ");
770 for (
int i = 0;
i < dbSchemaRows.Length;
i++)
779 if (mappings !=
null && dataRow !=
null)
790 if (columnValue ==
obj || (columnValue !=
null && columnValue.Equals(
obj)))
799 stringBuilder.
Append(
" = ");
803 bool flag = num == 0;
804 num =
BuildWhereClause(mappings, dataRow, stringBuilder, dbCommand, num, isUpdate:
true);
805 dbCommand.CommandText = stringBuilder.
ToString();
817 string value =
string.Empty;
819 builder.
Append(
" WHERE ");
822 for (
int i = 0;
i < dbSchemaRows.Length;
i++)
829 object value2 =
null;
832 if (mappings !=
null && dataRow !=
null)
854 builder.
Append(
" IS NULL");
888 return parameterCount;
894 if (parameterName ==
null)
900 nextParameter.ParameterName = parameterName;
903 nextParameter.SourceColumn = sourceColumn;
904 nextParameter.SourceVersion = version;
905 nextParameter.SourceColumnNullMapping =
true;
906 nextParameter.Value =
value;
907 nextParameter.Size = 0;
909 nextParameter.DbType =
DbType.Int32;
915 if (parameterName ==
null)
925 if (parameterName ==
null)
931 nextParameter.ParameterName = parameterName;
934 nextParameter.SourceColumn = sourceColumn;
935 nextParameter.SourceVersion = version;
936 nextParameter.SourceColumnNullMapping =
false;
937 nextParameter.Value =
value;
938 nextParameter.Size = 0;
944 if (parameterName ==
null)
951 protected override void Dispose(
bool disposing)
969 if (dataAdapter !=
null)
1014 if (dataAdapter !=
null)
1022 if (dbCommand ==
null)
1041 BuildCache(closeConnection:
true, dataRow, useColumnsForParameterNames);
1058 BuildCache(closeConnection:
true, dataRow, useColumnsForParameterNames);
1075 BuildCache(closeConnection:
true, dataRow, useColumnsForParameterNames);
1085 [
return: NotNullIfNotNull(
"column")]
1088 object result =
null;
1091 result = row[column, version];
1099 if (!
string.IsNullOrEmpty(columnName))
1146 flag = !row.IsLong && !row.IsRowVersion && !row.
IsHidden;
1154 switch (conflictOption)
1176 if (command ==
null)
1205 if (dataAdapter !=
null)
1209 dataAdapter.InsertCommand =
null;
1213 dataAdapter.UpdateCommand =
null;
1217 dataAdapter.DeleteCommand =
null;
1240 for (
int num = command.
Parameters.
Count - 1; num >= usedParameterCount; num--)
1248 if (rowUpdatingEvent ==
null)
1254 if (rowUpdatingEvent.
Status != 0)
1260 if (dbCommand !=
null)
1262 switch (statementType)
1278 if (dbCommand != rowUpdatingEvent.
Command)
1281 if (dbCommand !=
null && dbCommand.
Connection ==
null)
1284 if (dbCommand2 !=
null)
1286 dbCommand.Connection = dbCommand2.
Connection;
1295 if (dbCommand ==
null)
1304 rowUpdatingEvent.Errors = ex;
1311 BuildCache(closeConnection:
false, row, useColumnsForParameterNames:
false);
1312 DbCommand dbCommand = rowUpdatingEvent.StatementType
switch
1319 if (dbCommand ==
null)
1324 rowUpdatingEvent.Command = dbCommand;
static bool IsDBNull([NotNullWhen(true)] object? value)
static InvalidOperationException DynamicSQLNoKeyInfoUpdate()
static string BuildQuotedString(string quotePrefix, string quoteSuffix, string unQuotedString)
static ArgumentNullException ArgumentNull(string parameter)
static int SrcCompare(string strA, string strB)
static InvalidOperationException MissingSourceCommand()
static bool CompareInsensitiveInvariant(string strvalue, string strconst)
static ArgumentOutOfRangeException InvalidStatementType(StatementType value)
static InvalidOperationException DynamicSQLNoTableInfo()
static InvalidOperationException DynamicSQLNoKeyInfoRowVersionUpdate()
static ArgumentOutOfRangeException InvalidCatalogLocation(CatalogLocation value)
static void TraceExceptionForCapture(Exception e)
static InvalidOperationException NoQuoteChange()
static InvalidOperationException MissingSourceCommandConnection()
static NotSupportedException NotSupported()
static InvalidOperationException DynamicSQLNoKeyInfoRowVersionDelete()
static void BuildSchemaTableInfoTableNames(string[] columnNameArray)
static InvalidOperationException DynamicSQLNestedQuote(string name, string quote)
static bool IsCatchableExceptionType(Exception e)
static InvalidOperationException DynamicSQLJoinUnsupported()
static bool IsNull(object value)
static InvalidOperationException DynamicSQLNoKeyInfoDelete()
static ArgumentOutOfRangeException InvalidConflictOptions(ConflictOption value)
MissingMappingAction MissingMappingAction
override void Dispose(bool disposing)
DataColumn? GetDataColumn(string sourceColumn, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicProperties)] Type? dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction)
void ApplyProviderSpecificFormat()
void SetAndValidateNamePrefixes()
int _genericParameterCount
readonly string[] _nullParameterNames
readonly int _adjustedParameterNameMaxLength
readonly Regex _parameterNameParser
string GetNextGenericParameterName()
readonly string[] _originalParameterNames
readonly string[] _baseParameterNames
void EliminateConflictingNames()
int GetAdjustedParameterNameMaxLength()
void GenerateMissingNames(DbSchemaRow[] schemaRows)
readonly DbCommandBuilder _dbCommandBuilder
ParameterNames(DbCommandBuilder dbCommandBuilder, DbSchemaRow[] schemaRows)
string GetOriginalParameterName(int index)
string GetBaseParameterName(int index)
readonly bool[] _isMutatedName
string GetNullParameterName(int index)
object GetColumnValue(DataRow row, string columnName, DataTableMapping mappings, DataRowVersion version)
string GetParameterPlaceholder(int parameterOrdinal)
string QuotedColumn(string column)
virtual string QuoteSuffix
DbCommand GetUpdateCommand(bool useColumnsForParameterNames)
bool IncludeInUpdateSet(DbSchemaRow row)
static void RemoveExtraParameters(DbCommand command, int usedParameterCount)
ConflictOption _conflictDetection
override void Dispose(bool disposing)
string? ParameterNamePattern
DbCommand GetDeleteCommand(DataRow dataRow, bool useColumnsForParameterNames)
DbCommand GetSelectCommand()
DataColumn GetDataColumn(string columnName, DataTableMapping tablemapping, DataRow row)
string _parameterNamePattern
string CreateParameterForValue(DbCommand command, string parameterName, string sourceColumn, DataRowVersion version, int parameterCount, object value, DbSchemaRow row, StatementType statementType, bool whereClause)
string _parameterMarkerFormat
void ApplyParameterInfo(DbParameter parameter, DataRow row, StatementType statementType, bool whereClause)
DbDataAdapter? DataAdapter
static DbParameter GetNextParameter(DbCommand command, int pcount)
DbCommand BuildUpdateCommand(DataTableMapping mappings, DataRow dataRow)
string[] _sourceColumnNames
virtual DbCommand InitializeCommand(DbCommand? command)
virtual string QuotePrefix
void BuildCache(bool closeConnection, DataRow dataRow, bool useColumnsForParameterNames)
CatalogLocation _catalogLocation
string GetNullParameterName(int index)
virtual void RefreshSchema()
virtual string SchemaSeparator
string _quotedBaseTableName
virtual CatalogLocation CatalogLocation
string GetParameterName(int parameterOrdinal)
DbCommand GetUpdateCommand()
DbCommand GetInsertCommand()
int BuildWhereClause(DataTableMapping mappings, DataRow dataRow, StringBuilder builder, DbCommand command, int parameterCount, bool isUpdate)
ParameterNames _parameterNames
DbCommand GetDeleteCommand()
void SetRowUpdatingHandler(DbDataAdapter adapter)
DbCommand BuildInsertCommand(DataTableMapping mappings, DataRow dataRow)
string? QuotedBaseTableName
bool IncrementWhereCount(DbSchemaRow row)
string CreateParameterForNullTest(DbCommand command, string parameterName, string sourceColumn, DataRowVersion version, int parameterCount, object value, DbSchemaRow row, StatementType statementType, bool whereClause)
DbCommand GetDeleteCommand(bool useColumnsForParameterNames)
void BuildInformation(DataTable schemaTable)
virtual ConflictOption ConflictOption
int ParameterNameMaxLength
MissingMappingAction _missingMappingAction
object GetColumnValue(DataRow row, DataColumn column, DataRowVersion version)
virtual string UnquoteIdentifier(string quotedIdentifier)
DbSchemaRow[] _dbSchemaRows
bool IncludeInWhereClause(DbSchemaRow row, bool isUpdate)
DataTableMapping GetTableMapping(DataRow dataRow)
void RowUpdatingHandlerBuilder(RowUpdatingEventArgs rowUpdatingEvent)
int _parameterNameMaxLength
DbCommand BuildDeleteCommand(DataTableMapping mappings, DataRow dataRow)
DbCommand GetUpdateCommand(DataRow dataRow, bool useColumnsForParameterNames)
bool IncludeInInsertValues(DbSchemaRow row)
DbDataAdapter _dataAdapter
DbCommand GetInsertCommand(bool useColumnsForParameterNames)
string GetOriginalParameterName(int index)
virtual string CatalogSeparator
DbCommand GetInsertCommand(DataRow dataRow, bool useColumnsForParameterNames)
string GetParameterName(string parameterName)
string GetBaseParameterName(int index)
bool _hasPartialPrimaryKey
void RowUpdatingHandler(RowUpdatingEventArgs rowUpdatingEvent)
virtual ? DataTable GetSchemaTable(DbCommand sourceCommand)
virtual string QuoteIdentifier(string unquotedIdentifier)
DbParameterCollection Parameters
DbTransaction? Transaction
DbParameter CreateParameter()
DbDataReader ExecuteReader()
DbCommand CreateCommand()
virtual DataTable GetSchema()
static readonly object s_parameterValueNonNullValue
DataTableMapping GetTableMapping(DataTable dataTable)
virtual ? DataTable GetSchemaTable()
int IList. Add(object value)
bool IList. Contains(object value)
static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool returnProviderSpecificTypes)
DataTableMapping TableMapping
StatementType StatementType
static CultureInfo InvariantCulture
static byte Max(byte val1, byte val2)
static bool IsMatch(string input, string pattern)
override string ToString()
StringBuilder Append(char value, int repeatCount)
DesignerSerializationVisibility