Class MSSqlConnectionProvider
- Namespace
- DevExpress.Xpo.DB
- Assembly
- DevExpress.Xpo.v24.1.dll
Implements data-aware operations for working with an Microsoft SQL Server or Microsoft SQL Azure database.
public class MSSqlConnectionProvider : ConnectionProviderSql
- Inheritance
-
MSSqlConnectionProvider
Constructors
MSSqlConnectionProvider(IDbConnection, AutoCreateOption)
Initializes a new instance of the MSSqlConnectionProvider class with the specified settings.
public MSSqlConnectionProvider(IDbConnection connection, AutoCreateOption autoCreateOption)
Parameters
connection
IDbConnectionAn object implementing the IDbConnection interface that represents an open connection to a data source.
autoCreateOption
AutoCreateOptionAn DevExpress.Xpo.DB.AutoCreateOption value that specifies which operations are performed when storage is accessed for the first time. This parameter is used to initialize the IDataStore.AutoCreateOption property.
Fields
IsNotForReplication
Specifies whether or not the “NOT FOR REPLICATION” option is used in SQL statements that create constraints.
public static bool IsNotForReplication
Field Value
MaximumBinarySize
This member supports the internal infrastructure and is not intended to be used directly from your code.
public const int MaximumBinarySize = 8000
Field Value
MaximumStringSize
This member supports the internal infrastructure and is not intended to be used directly from your code.
public const int MaximumStringSize = 4000
Field Value
ObjectsOwner
The default owner of the objects in the Microsoft SQL database. By default “dbo”.
public string ObjectsOwner
Field Value
XpoProviderTypeString
Gets the name of the current connection provider. This name is used internally when generating a connection string via the MSSqlConnectionProvider.GetConnectionString method.
public const string XpoProviderTypeString = "MSSqlServer"
Field Value
Properties
CreateForeignKeyTemplate
protected override string CreateForeignKeyTemplate { get; }
Property Value
DbTypeMapper
protected override DbTypeMapperBase DbTypeMapper { get; }
Property Value
- DbTypeMapperBase
NativeOuterApplySupported
Indicates whether the connection provider supports the OUTER APPLY operators.
public override bool NativeOuterApplySupported { get; }
Property Value
- bool
true for Microsoft SQL Server version 2005 and later; otherwise, false.
NativeSkipTakeSupported
Indicates whether the connection provider supports the SKIP and TAKE (TOP) operators.
public override bool NativeSkipTakeSupported { get; }
Property Value
- bool
true for Microsoft SQL Server version 2005 and later; otherwise, false.
UpdateSchemaFormatter
protected override UpdateSchemaSqlFormatterHelper UpdateSchemaFormatter { get; }
Property Value
- UpdateSchemaSqlFormatterHelper
Methods
ClearDatabase(IDbCommand)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public static void ClearDatabase(IDbCommand command)
Parameters
command
IDbCommand
CollectTablesToCreate(ICollection)
This method supports the internal infrastructure and is not intended to be called directly from your code.
public override ICollection CollectTablesToCreate(ICollection tables)
Parameters
tables
ICollection
Returns
CommandBuilderDeriveParameters(IDbCommand)
protected override void CommandBuilderDeriveParameters(IDbCommand command)
Parameters
command
IDbCommand
CommandExecuteNonQueryAsync(IDbCommand, AsyncOperationIdentifier, CancellationToken)
protected override Task<int> CommandExecuteNonQueryAsync(IDbCommand command, AsyncOperationIdentifier asyncOperationId, CancellationToken cancellationToken)
Parameters
command
IDbCommandasyncOperationId
AsyncOperationIdentifiercancellationToken
CancellationToken
Returns
CommandExecuteReaderAsync(IDbCommand, CommandBehavior, AsyncOperationIdentifier, CancellationToken)
protected override Task<IDataReader> CommandExecuteReaderAsync(IDbCommand command, CommandBehavior commandBehavior, AsyncOperationIdentifier asyncOperationId, CancellationToken cancellationToken)
Parameters
command
IDbCommandcommandBehavior
CommandBehaviorasyncOperationId
AsyncOperationIdentifiercancellationToken
CancellationToken
Returns
CommandExecuteScalarAsync(IDbCommand, AsyncOperationIdentifier, CancellationToken)
protected override Task<object> CommandExecuteScalarAsync(IDbCommand command, AsyncOperationIdentifier asyncOperationId, CancellationToken cancellationToken)
Parameters
command
IDbCommandasyncOperationId
AsyncOperationIdentifiercancellationToken
CancellationToken
Returns
ComposeSafeSchemaName(string)
Returns the valid schema name for the specified table’s name.
public override string ComposeSafeSchemaName(string tableName)
Parameters
tableName
stringA string value that specifies the table’s name for which the valid schema name must be composed.
Returns
- string
A string value that specifies the valid schema name.
ConvertToDbParameter(object, TypeCode)
protected override object ConvertToDbParameter(object clientValue, TypeCode clientValueTypeCode)
Parameters
Returns
CreateConnection()
protected override IDbConnection CreateConnection()
Returns
CreateConnection(string)
For internal use.
public static IDbConnection CreateConnection(string connectionString)
Parameters
connectionString
string
Returns
CreateDataBase()
protected override void CreateDataBase()
CreateParameter(IDbCommand, object, string, DBColumnType, string, int)
protected override IDataParameter CreateParameter(IDbCommand command, object value, string name, DBColumnType dbType, string dbTypeName, int size)
Parameters
command
IDbCommandvalue
objectname
stringdbType
DBColumnTypedbTypeName
stringsize
int
Returns
CreateProviderFromConnection(IDbConnection, AutoCreateOption)
This method supports the internal infrastructure and is not intended to be called directly from your code.
public static IDataStore CreateProviderFromConnection(IDbConnection connection, AutoCreateOption autoCreateOption)
Parameters
connection
IDbConnectionautoCreateOption
AutoCreateOption
Returns
- IDataStore
CreateProviderFromString(string, AutoCreateOption, out IDisposable[])
This method supports the internal infrastructure and is not intended to be called directly from your code.
public static IDataStore CreateProviderFromString(string connectionString, AutoCreateOption autoCreateOption, out IDisposable[] objectsToDisposeOnDisconnect)
Parameters
connectionString
stringautoCreateOption
AutoCreateOptionobjectsToDisposeOnDisconnect
IDisposable[]
Returns
- IDataStore
CreateSchemaComparer()
protected override DBSchemaComparerSql CreateSchemaComparer()
Returns
- DBSchemaComparerSql
EmptyAllTablesInDatabase(IDbCommand)
This method supports the internal infrastructure and is not intended to be used directly in your code.
public static void EmptyAllTablesInDatabase(IDbCommand command)
Parameters
command
IDbCommand
FormatBinary(BinaryOperatorType, string, string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatBinary(BinaryOperatorType operatorType, string leftOperand, string rightOperand)
Parameters
Returns
FormatColumn(string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatColumn(string columnName)
Parameters
columnName
string
Returns
FormatColumn(string, string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatColumn(string columnName, string tableAlias)
Parameters
Returns
FormatConstraint(string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatConstraint(string constraintName)
Parameters
constraintName
string
Returns
FormatDelete(string, string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatDelete(string tableName, string whereClause)
Parameters
Returns
FormatFunction(FunctionOperatorType, params string[])
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatFunction(FunctionOperatorType operatorType, params string[] operands)
Parameters
operatorType
FunctionOperatorTypeoperands
string[]
Returns
FormatFunction(ProcessParameter, FunctionOperatorType, params object[])
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatFunction(ProcessParameter processParameter, FunctionOperatorType operatorType, params object[] operands)
Parameters
processParameter
ProcessParameteroperatorType
FunctionOperatorTypeoperands
object[]
Returns
FormatInsert(string, string, string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatInsert(string tableName, string fields, string values)
Parameters
Returns
FormatInsertDefaultValues(string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatInsertDefaultValues(string tableName)
Parameters
tableName
string
Returns
FormatSelect(string, string, string, string, string, string, int, int)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatSelect(string selectedPropertiesSql, string fromSql, string whereSql, string orderBySql, string groupBySql, string havingSql, int skipSelectedRecords, int topSelectedRecords)
Parameters
selectedPropertiesSql
stringfromSql
stringwhereSql
stringorderBySql
stringgroupBySql
stringhavingSql
stringskipSelectedRecords
inttopSelectedRecords
int
Returns
FormatTable(string, string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatTable(string schema, string tableName)
Parameters
Returns
FormatTable(string, string, string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatTable(string schema, string tableName, string tableAlias)
Parameters
Returns
FormatUpdate(string, string, string)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override string FormatUpdate(string tableName, string sets, string whereClause)
Parameters
Returns
GenerateStoredProcedures(DBTable, out string)
Generates DDL (Data Description Language) code for the Generating Persistent Classes wizard, when mapping persistent classes to Microsoft SQL Server database views with the help of INSTEAD-OF triggers and stored procedures.
public override string GenerateStoredProcedures(DBTable table, out string dropLines)
Parameters
table
DBTabledropLines
string
Returns
GetConnectionString(string, int, string)
Returns a connection string used to open a specified Microsoft SQL database using provided login credentials.
public static string GetConnectionString(string server, int port, string database)
Parameters
server
stringA string that specifies the SQL server’s name.
port
intAn integer that specifies the server’s port number.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionString(string, int, string, string, string)
Returns a connection string used to open a specified Microsoft SQL database using provided login credentials.
public static string GetConnectionString(string server, int port, string userId, string password, string database)
Parameters
server
stringA string that specifies the SQL server’s name.
port
intAn integer that specifies the server’s port number.
userId
stringA string that specifies a user name.
password
stringA string that specifies a password.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionString(string, string)
Returns a connection string used to open a specified Microsoft SQL database using Windows Integrated Security.
public static string GetConnectionString(string server, string database)
Parameters
server
stringA string that specifies the SQL server name.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionString(string, string, string, string)
Returns a connection string used to open a specified Microsoft SQL database using provided login credentials.
public static string GetConnectionString(string server, string userId, string password, string database)
Parameters
server
stringA string that specifies the SQL server’s name.
userId
stringA string that specifies a user name.
password
stringA string that specifies a password.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionString2005CacheRoot(string, string)
Returns a connection string used to open a specified Microsoft SQL database using Windows Integrated Security and to enable the SqlDependency feature.
public static string GetConnectionString2005CacheRoot(string server, string database)
Parameters
server
stringA string that specifies the SQL server name.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionString2005CacheRoot(string, string, string, string)
Returns a connection string used to open a specified Microsoft SQL database using provided login credentials and to enable the SqlDependency feature.
public static string GetConnectionString2005CacheRoot(string server, string userId, string password, string database)
Parameters
server
stringA string that specifies the SQL server name.
userId
stringA string that specifies a user name.
password
stringA string that specifies a user password.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionString2005WithCache(string, string)
Returns a connection string used to open a specified Microsoft SQL database using Windows Integrated Security and to enable the SqlDependency feature.
public static string GetConnectionString2005WithCache(string server, string database)
Parameters
server
stringA string that specifies the SQL server name.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionString2005WithCache(string, string, string, string)
Returns a connection string used to open a specified Microsoft SQL database using provided login credentials and to enable the SqlDependency feature.
public static string GetConnectionString2005WithCache(string server, string userId, string password, string database)
Parameters
server
stringA string that specifies the SQL server name.
userId
stringA string that specifies a user name.
password
stringA string that specifies a user password.
database
stringA string that specifies the database name.
Returns
- string
A connection string.
GetConnectionStringForType(string, string, int, string)
protected static string GetConnectionStringForType(string providerTypeString, string server, int port, string database)
Parameters
Returns
GetConnectionStringForType(string, string, int, string, string, string)
protected static string GetConnectionStringForType(string providerTypeString, string server, int port, string userId, string password, string database)
Parameters
Returns
GetConnectionStringForType(string, string, string)
protected static string GetConnectionStringForType(string providerTypeString, string server, string database)
Parameters
Returns
GetConnectionStringForType(string, string, string, string, string)
protected static string GetConnectionStringForType(string providerTypeString, string server, string userId, string password, string database)
Parameters
Returns
GetConnectionStringForTypeWithAttach(string, string, string, bool)
protected static string GetConnectionStringForTypeWithAttach(string providerTypeString, string server, string attachDbFilename, bool userInstance)
Parameters
Returns
GetConnectionStringForTypeWithAttach(string, string, string, string, string, bool)
protected static string GetConnectionStringForTypeWithAttach(string providerTypeString, string server, string userId, string password, string attachDbFilename, bool userInstance)
Parameters
providerTypeString
stringserver
stringuserId
stringpassword
stringattachDbFilename
stringuserInstance
bool
Returns
GetConnectionStringForTypeWithAttachForLocalDB(string, string, string, string)
protected static string GetConnectionStringForTypeWithAttachForLocalDB(string providerTypeString, string server, string database, string attachDbFilename)
Parameters
Returns
GetConnectionStringWithAttach(string, string, bool)
Returns a connection string to connect to a Microsoft SQL Server database by attaching a specified .mdf database file to a specific server using Windows Integrated Security.
public static string GetConnectionStringWithAttach(string server, string attachDbFilename, bool userInstance)
Parameters
server
stringA string that specifies the SQL server name.
attachDbFilename
stringA string specifying a .mdf database file to attach to the server. This value is used to initialize the “AttachDbFilename” field of the connection string.
userInstance
booltrue to enable User Instances (required when attaching the attachDbFilename); otherwise, false (when the database specified by the attachDbFilename already exists on the server). For more information about SQL Server Express and User Instances, read the SQL Server 2005 Express Edition User Instances MSDN article.
Returns
- string
A connection string.
GetConnectionStringWithAttach(string, string, string, string, bool)
Returns a connection string to connect to a Microsoft SQL Server database by attaching a specified .mdf database file to a specific server using specified login credentials.
public static string GetConnectionStringWithAttach(string server, string userId, string password, string attachDbFilename, bool userInstance)
Parameters
server
stringA string that specifies the SQL server name.
userId
stringA string that specifies a user name.
password
stringA string that specifies the password. This is used to initialize the “Password” field of the connection string.
attachDbFilename
stringA string specifying a .mdf database file to attach to the server. This value is used to initialize the “AttachDbFilename” field of the connection string.
userInstance
booltrue to enable User Instances (required when attaching the attachDbFilename); otherwise, false (when the database specified by the attachDbFilename already exists on the server). This value is used to initialize the “User Instance” field of the connection string.For more information about SQL Server Express and User Instances, read the SQL Server 2005 Express Edition User Instances MSDN article.
Returns
- string
A connection string.
GetConnectionStringWithAttachForLocalDB(string, string, string)
Returns the connection string to SQL Server 2012 Express LocalDB for the specified server, database and database file location.
public static string GetConnectionStringWithAttachForLocalDB(string server, string database, string attachDbFilename)
Parameters
server
stringA string that is the server name.
database
stringA string that is the database name.
attachDbFilename
stringA string that is the path to the MDB file.
Returns
- string
A string that is the connection string to SQL Server 2012 Express LocalDB for the specified server, database and database file location.
GetIdentity(Query)
protected override long GetIdentity(Query sql)
Parameters
sql
Query
Returns
GetIdentityAsync(Query, AsyncOperationIdentifier, CancellationToken)
protected override Task<long> GetIdentityAsync(Query sql, AsyncOperationIdentifier asyncOperationId, CancellationToken cancellationToken)
Parameters
sql
QueryasyncOperationId
AsyncOperationIdentifiercancellationToken
CancellationToken
Returns
GetParameterName(OperandValue, int, ref bool)
This member supports the .NET Framework infrastructure and cannot be used directly from your code.
public override string GetParameterName(OperandValue parameter, int index, ref bool createParameter)
Parameters
Returns
GetQueryParameterMode()
protected override QueryParameterMode GetQueryParameterMode()
Returns
- QueryParameterMode
GetSafeNameRoot(string)
protected override string GetSafeNameRoot(string originalName)
Parameters
originalName
string
Returns
GetSafeNameTableMaxLength()
protected override int GetSafeNameTableMaxLength()
Returns
GetSqlCreateColumnFullAttributes(DBTable, DBColumn)
This method supports the internal infrastructure and is not intended to be used directly from your code.
public override string GetSqlCreateColumnFullAttributes(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnFullAttributes(DBTable, DBColumn, bool)
public override string GetSqlCreateColumnFullAttributes(DBTable table, DBColumn column, bool forTableCreate)
Parameters
table
DBTablecolumn
DBColumnforTableCreate
bool
Returns
GetSqlCreateColumnTypeForBoolean(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForBoolean(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForByte(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForByte(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForByteArray(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForByteArray(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForChar(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForChar(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForDateTime(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForDateTime(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForDecimal(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForDecimal(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForDouble(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForDouble(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForGuid(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForGuid(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForInt16(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForInt16(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForInt32(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForInt32(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForInt64(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForInt64(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForSByte(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForSByte(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForSingle(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForSingle(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForString(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForString(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForUInt16(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForUInt16(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForUInt32(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForUInt32(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetSqlCreateColumnTypeForUInt64(DBTable, DBColumn)
protected override string GetSqlCreateColumnTypeForUInt64(DBTable table, DBColumn column)
Parameters
table
DBTablecolumn
DBColumn
Returns
GetStorageTablesList(bool)
Returns a list of the available tables in the data store.
public override string[] GetStorageTablesList(bool includeViews)
Parameters
includeViews
booltrue, to include available database views in the resulting array; otherwise, false.
Returns
- string[]
An array of the table names in the data store.
GetStoredProcedures()
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override DBStoredProcedure[] GetStoredProcedures()
Returns
- DBStoredProcedure[]
GetTableSchema(DBTable, bool, bool)
This member supports the internal infrastructure and is not intended to be used directly from your code.
public override void GetTableSchema(DBTable table, bool checkIndexes, bool checkForeignKeys)
Parameters
IsDeadLock(Exception)
protected override bool IsDeadLock(Exception e)
Parameters
Returns
ProcessClearDatabase()
protected override void ProcessClearDatabase()
ProcessModifyData(params ModificationStatement[])
protected override ModificationResult ProcessModifyData(params ModificationStatement[] dmlStatements)
Parameters
dmlStatements
ModificationStatement[]
Returns
- ModificationResult
ProcessModifyDataAsync(AsyncOperationIdentifier, CancellationToken, params ModificationStatement[])
protected override Task<ModificationResult> ProcessModifyDataAsync(AsyncOperationIdentifier asyncOperationId, CancellationToken cancellationToken, params ModificationStatement[] dmlStatements)
Parameters
asyncOperationId
AsyncOperationIdentifiercancellationToken
CancellationTokendmlStatements
ModificationStatement[]
Returns
- Task<ModificationResult>
ReaderNextResultAsync(IDataReader, AsyncOperationIdentifier, CancellationToken)
protected override Task<bool> ReaderNextResultAsync(IDataReader reader, AsyncOperationIdentifier asyncOperationId, CancellationToken cancellationToken)
Parameters
reader
IDataReaderasyncOperationId
AsyncOperationIdentifiercancellationToken
CancellationToken
Returns
ReaderReadAsync(IDataReader, AsyncOperationIdentifier, CancellationToken)
protected override Task<bool> ReaderReadAsync(IDataReader reader, AsyncOperationIdentifier asyncOperationId, CancellationToken cancellationToken)
Parameters
reader
IDataReaderasyncOperationId
AsyncOperationIdentifiercancellationToken
CancellationToken
Returns
Register()
Registers the provider for use with XPO.
public static void Register()
WrapException(Exception, IDbCommand)
protected override Exception WrapException(Exception e, IDbCommand query)
Parameters
e
Exceptionquery
IDbCommand