Skip to content

SqlServerConnection Class ​

Definition ​

Connection to a Sql Server Database

  • Namespace: JASE.Database.Connections
  • Assembly: JASE.Database.dll

Properties ​

NameDescription
AllowMultipleResultSetsEnable Multiple Active Result Sets (MARS) on Connections to SQL Server
DatabaseTypeString representing the type of database
EncryptConnectionsValue for Encrypt key in a generated connection string (Default: true)
IsAzureHostedReturns TRUE if connection is detected as being hosted in Azure
MaxPoolSizeSet connection string pool size in a generated connection string (Default: 100)
MinPoolSizeSet connection string pool size in a generated connection string (Default: 0)
SqlGeneratorA SqlGenerator for the currently connected database
TrustServerCertificateValue for TrustServerCertificate key in a generated connection string (Default: false)

Methods ​

NameDescription
string BuildConnectionString(DatabaseConfig dbConfig)Builds a SQL Server specific connection string based on provided Database Configuration
string BuildConnectionString(string server, string database, IAuthenticationCredential credentials, IReadOnlyDictionary<string, string> configParams, int port = null)Builds a SQL Server specific connection string based on provided values
bool ChangeDatabase(string database)Change to the requested database
Task<bool> ChangeDatabaseAsync(string database)Change to the requested database
bool CheckDatabaseExist(string database)Check if the specified database exist
bool CheckSchemaExist(string schema)Checks if the specified Schema exist in the database
bool CheckTableExist(string table, string schema = null)Checks if the specified Table exist in the database
Task<bool> CheckTableExistAsync(string table, string schema = null)Checks if the specified Table exist in the database
bool CreateSchema(string name, string authorization = null, string comment = null)Create a schema in the database
Task<bool> CreateSchemaAsync(string name, string authorization = null, string comment = null)Create a schema in the database
Task<bool> DropConstraintAsync(ISelectable selectable, string constraint)Drop the requested Constraint from the table
Task<bool> DropConstraintAsync(string table, string constraint)Drop the requested Constraint from the table
bool DropSchema(string schema)Execute a DROP command for the specified schema
Task<bool> DropSchemaAsync(string schema)Execute a DROP command for the specified schema
bool DropTable(string table)Execute a DROP command for the named table
bool DropTables(IEnumerable<string> tables)Execute a DROP command for multiple tables
Task<bool> DropTablesAsync(IEnumerable<string> tables)Execute a DROP command for multiple tables
Guid GenerateUuid()Generate a UUID byte ordered for the current connection type
string GetCollation()Returns the Collation for the current connection
string GetCollation(string database)Returns the Collation for the current connection
Task<string> GetCollationAsync()Returns the Collation for the current connection
Task<string> GetCollationAsync(string database)Returns the Collation for the current connection
Task<IReadOnlyList<Constraint>> GetConstraintsAsync(ISelectable selectable, int commandTimeout = null)Returns constraints for the given table. Empty list when the table is missing or has none (never null on success).
Task<IReadOnlyList<Constraint>> GetConstraintsAsync(int commandTimeout = null)Returns constraints in the database. Empty list when none exist (never null on success).
Task<IReadOnlyList<Constraint>> GetConstraintsAsync(string schema, int commandTimeout = null)Returns constraints filtered by schema. Empty list when the schema is missing or has none (never null on success).
Task<IReadOnlyList<IndexInformation>> GetIndexesAsync(int commandTimeout = null)Retrieve all indexes from the database. Empty list when none exist (never null on success).
Task<IReadOnlyList<IndexInformation>> GetIndexesAsync(string schema, int commandTimeout = null)Retrieve indexes from a specific database schema. Empty list when none exist (never null on success).
Task<IReadOnlyList<IndexInformation>> GetIndexesByTable(ITableInfo table, int commandTimeout = null)Retrieve indexes for a specific table. Empty list when none exist (never null on success).
int GetPid()Obtain the connections Process ID
Task<int> GetPidAsync()Obtain the connections Process ID
TableInfo GetTableInfo(string schema, string table, bool includeIndexes, bool includeConstraints, int commandTimeout = null)Returns information about the specified database table
Task<IReadOnlyList<TableInfo>> GetTableInfoAsync(string schema, bool includeIndexes, bool includeConstraints, int commandTimeout = null)Returns information about the specified database table
Task<TableInfo> GetTableInfoAsync(string schema, string table, bool includeIndexes, bool includeConstraints, int commandTimeout = null)Returns information about the specified database table
IReadOnlyList<string> GetTableList(int commandTimeout = null)Returns a List of tables in the current database
IReadOnlyList<string> GetTableList(string schema, int commandTimeout = null)Returns a List of tables limited by the schema name
Task<IReadOnlyList<string>> GetTableListAsync(string schema, int commandTimeout = null)Returns a List of tables limited by the schema name
string GetVersion()Returns version of the current database in string format
Task<string> GetVersionAsync()Returns version of the current database in string format