Class SqlServerSchemaLoader
The implementation of IDatabaseSchemaLoader<T> for Microsoft SQL Server.
Inheritance
Namespace: Kros.Data.Schema.SqlServer
Assembly: Kros.Utils.dll
Syntax
public class SqlServerSchemaLoader : IDatabaseSchemaLoader<SqlConnection>, IDatabaseSchemaLoader
Methods
GetDefaultValueString(String)
Adjusts the string rawDefaultValueString so column's default value can be obtained from it.
Declaration
protected virtual string GetDefaultValueString(string rawDefaultValueString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | rawDefaultValueString | Default value string as it is stored in database. |
Returns
| Type | Description |
|---|---|
| System.String | Adjusted string - trimmed of unneeded characters. |
LoadSchema(SqlConnection)
Loads database schema for connection.
Declaration
public DatabaseSchema LoadSchema(SqlConnection connection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Data.SqlClient.SqlConnection | connection | Database connection. |
Returns
| Type | Description |
|---|---|
| DatabaseSchema | Database schema. |
Remarks
Loading schema creates a new connection to database based on connection. If loading with
new connection fails (for example input connection is exclusive), schema is loaded using input
connection directly.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | |
| System.ArgumentException | Initial catalog of |
LoadTableSchema(SqlConnection, String)
Loads table schema for table tableName in database connection.
Declaration
public TableSchema LoadTableSchema(SqlConnection connection, string tableName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Data.SqlClient.SqlConnection | connection | Database connection. |
| System.String | tableName | Table name. |
Returns
| Type | Description |
|---|---|
| TableSchema | Table schema, or value null if specified table does not exist. |
Remarks
Loading schema creates a new connection to database based on connection. If loading with
new connection fails (for example input connection is exclusive), schema is loaded using input
connection directly.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | |
| System.ArgumentException |
OnParseDefaultValue(SqlServerParseDefaultValueEventArgs)
Raises the ParseDefaultValue event with arguments e.
Declaration
protected virtual void OnParseDefaultValue(SqlServerParseDefaultValueEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| SqlServerParseDefaultValueEventArgs | e | Arguments for the event. |
SupportsConnectionType(SqlConnection)
Checks if it is poosible to load database schema for connection.
Declaration
public bool SupportsConnectionType(SqlConnection connection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Data.SqlClient.SqlConnection | connection | Database connection. |
Returns
| Type | Description |
|---|---|
| System.Boolean | false if value of |
Events
ParseDefaultValue
Event raised while parsing default value of a column. It is possible to use custom parsing logic in the event handler.
Declaration
public event EventHandler<SqlServerParseDefaultValueEventArgs> ParseDefaultValue
Event Type
| Type | Description |
|---|---|
| System.EventHandler<SqlServerParseDefaultValueEventArgs> |
Remarks
When custom logic for parsing column's default value is used, the parsed value is set in DefaultValue property and Handled flag must be set to true.
Explicit Interface Implementations
IDatabaseSchemaLoader.LoadSchema(Object)
Loads database schema for connection.
Declaration
DatabaseSchema IDatabaseSchemaLoader.LoadSchema(object connection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | connection | Database connection. |
Returns
| Type | Description |
|---|---|
| DatabaseSchema | Database schema. |
Remarks
Loading schema creates a new connection to database based on connection. If loading with
new connection fails (for example input connection is exclusive), schema is loaded using input
connection directly.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | |
| System.ArgumentException |
IDatabaseSchemaLoader.LoadTableSchema(Object, String)
Loads table schema for table tableName in database connection.
Declaration
TableSchema IDatabaseSchemaLoader.LoadTableSchema(object connection, string tableName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | connection | Database connection. |
| System.String | tableName | Table name. |
Returns
| Type | Description |
|---|---|
| TableSchema | Table schema, or value null if specified table does not exist. |
Remarks
Loading schema creates a new connection to database based on connection. If loading with
new connection fails (for example input connection is exclusive), schema is loaded using input
connection directly.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | |
| System.ArgumentException |
IDatabaseSchemaLoader.SupportsConnectionType(Object)
Checks if it is poosible to load database schema for connection.
Declaration
bool IDatabaseSchemaLoader.SupportsConnectionType(object connection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | connection | Database connection. |
Returns
| Type | Description |
|---|---|
| System.Boolean | false if value of |