C# Класс SQLiteConversionEngine.Converters.BaseConverter

This class is resposible to take a single SQL Server database and convert it to an SQLite database file.
The class knows how to convert table and index structures only.
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
_cancelled bool
_defaultValueRx System.Text.RegularExpressions.Regex
_isActive bool
_keyRx System.Text.RegularExpressions.Regex

Открытые методы

Метод Описание
CancelConversion ( ) : void

Cancels the conversion.

ConvertToDatabase ( SqlConnection sqlConnection, SQLiteConnection sqliteConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void

This method takes as input the connection to an SQL Server database and creates a corresponding SQLite database file with a schema derived from the SQL Server database.

The method continues asynchronously in the background and the caller returned immediatly.

ConvertToDatabase ( string sqlServerConnectionString, SQLiteConnection sqliteConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void

This method takes as input the connection string to an SQL Server database and creates a corresponding SQLite database file with a schema derived from the SQL Server database.

The method continues asynchronously in the background and the caller returned immediatly.

ConvertToDatabase ( string sqlServerConnectionString, string sqliteConnectionString, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void

This method takes as input the connection string to an SQL Server database and creates a corresponding SQLite database file with a schema derived from the SQL Server database.

The method continues asynchronously in the background and the caller returned immediatly.

InitializeSQLiteConnection ( string sqliteConnectionString ) : SQLiteConnection
InitializeSQLiteDatabase ( SQLiteConnection sqliteConnection, List PragmaCommands ) : void
InitializeSqlServerConnection ( string sqlServerConnectionString ) : SqlConnection
InitializeSqlServerDatabase ( SqlConnection sqlConnection ) : void

Защищенные методы

Метод Описание
AddTriggersForForeignKeys ( SQLiteConnection sqliteConnection, IEnumerable schema, SqlConversionHandler handler ) : void
AddTriggersForForeignKeys ( string sqlitePath, IEnumerable schema, string password, SqlConversionHandler handler ) : void
AdjustDefaultValue ( string val ) : string

More adjustments for the DEFAULT value clause.

BuildIndexSchema ( string indexName, string desc, string keys ) : IndexSchema

Builds an index schema object from the specified components (Read from SQL Server).

BuildSQLiteInsert ( TableSchema ts ) : SQLiteCommand

Creates a command object needed to insert values into a specific SQLite table.

BuildSQLiteUpdate ( TableSchema ts ) : SQLiteCommand

Creates a command object needed to insert values into a specific SQLite table.

BuildSourceTableQuery ( TableSchema tableSchema ) : string

Builds a SELECT query for a specific table. Needed in the process of copying rows from the SQL Server database to the SQLite database.

BuildSqlServerInsert ( TableSchema ts ) : SqlCommand

Creates a command object needed to insert values into a specific SQLite table.

CastValueForColumn ( object val, ColumnSchema columnSchema ) : object

Used in order to adjust the value received from SQL Servr for the SQLite database.

CheckCancelled ( ) : void

Convenience method for checking if the conversion progress needs to be cancelled.

ConvertSourceDatabaseToDestination ( SqlConnection sqlConnection, SQLiteConnection sqliteConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void

Do the entire process of first reading the SQL Server schema, creating a corresponding SQLite schema, and copying all rows from the SQL Server database to the SQLite database.

CopySourceDatabaseRowsToDestination ( SqlConnection sqlConnection, SQLiteConnection sqliteConnection, List schema, SqlConversionHandler handler ) : void

Copies table rows from the SQL Server database to the SQLite database.

CreateForeignKeySchema ( IDbConnection sourceConnection, TableSchema tableSchema ) : void

Add foreign key schema object from the specified components (Read from SQL Server).

CreateSQLiteConnectionString ( string sqlitePath, string password ) : string

Creates SQLite connection string from the specified DB file path.

CreateSQLiteDatabase ( SQLiteConnection sqliteConnection, DatabaseSchema schema, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void

Creates the SQLite database.

CreateSQLiteDatabase ( string sqlitePath, DatabaseSchema schema, string password, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void

Creates the SQLite database from the schema read from the SQL Server.

CreateSqlServerConnectionString ( string sqlitePath, string password ) : string

Creates SQLite connection string from the specified DB file path.

CreateSqlServerDatabase ( SQLiteConnection sqliteConnection, DatabaseSchema schema, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void

Creates the SQLite database.

CreateSqlServerDatabase ( string sqlitePath, DatabaseSchema schema, string password, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void

Creates the SQLite database from the schema read from the SQL Server.

CreateTableSchema ( IDbConnection sourceConnection, string tableName, string tableSchemaName ) : TableSchema

Creates a TableSchema object using the specified SQL Server connection and the name of the table for which we need to create the schema.

FixDefaultValueString ( string colDefault ) : string

Does some necessary adjustments to a value string that appears in a column DEFAULT clause.

GetDbTypeOfColumn ( ColumnSchema columnSchema ) : DbType

Matches SQL Server types to general DB types

GetNormalizedName ( string str, List names ) : string

Used in order to avoid breaking naming rules (e.g., when a table has a name in SQL Server that cannot be used as a basis for a matching index name in SQLite).

ParseBlobAsGuid ( byte blob ) : System.Guid
ParseStringAsGuid ( string str ) : System.Guid
ReadSourceSchema ( SqlConnection sqlConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler ) : DatabaseSchema

Reads the entire SQL Server DB schema using the specified connection string.

ValidateDataType ( string dataType ) : void

Small validation method to make sure we don't miss anything without getting an exception.

WriteTriggerSchema ( TriggerSchema ts ) : string

Gets a create script for the triggerSchema in SQLite syntax

Приватные методы

Метод Описание
AddSQLiteTable ( SQLiteConnection conn, TableSchema dt ) : void

Creates the CREATE TABLE DDL for SQLite and a specific table.

AddSQLiteView ( SQLiteConnection conn, ViewSchema vs, FailedViewDefinitionHandler handler ) : void
AddTableTriggers ( SQLiteConnection conn, TableSchema dt ) : void
BuildColumnStatement ( ColumnSchema col, TableSchema ts, bool &pkey ) : string

Used when creating the CREATE TABLE DDL. Creates a single row for the specified column.

BuildCreateIndex ( string tableName, IndexSchema indexSchema ) : string

Creates a CREATE INDEX DDL for the specified table and index schema.

BuildCreateTableQuery ( TableSchema ts ) : string

returns the CREATE TABLE DDL for creating the SQLite table from the specified table schema object.

DiscardNational ( string value ) : string

Discards the national prefix if exists (e.g., N'sometext') which is not supported in SQLite.

IsSingleQuoted ( string value ) : bool
IsValidDefaultValue ( string value ) : bool

Check if the DEFAULT clause is valid by SQLite standards

StripParens ( string value ) : string

Strip any parentheses from the string.

Описание методов

AddTriggersForForeignKeys() защищенный статический Метод

protected static AddTriggersForForeignKeys ( SQLiteConnection sqliteConnection, IEnumerable schema, SqlConversionHandler handler ) : void
sqliteConnection System.Data.SQLite.SQLiteConnection
schema IEnumerable
handler SqlConversionHandler
Результат void

AddTriggersForForeignKeys() защищенный статический Метод

protected static AddTriggersForForeignKeys ( string sqlitePath, IEnumerable schema, string password, SqlConversionHandler handler ) : void
sqlitePath string
schema IEnumerable
password string
handler SqlConversionHandler
Результат void

AdjustDefaultValue() защищенный статический Метод

More adjustments for the DEFAULT value clause.
protected static AdjustDefaultValue ( string val ) : string
val string The value to adjust
Результат string

BuildIndexSchema() защищенный статический Метод

Builds an index schema object from the specified components (Read from SQL Server).
protected static BuildIndexSchema ( string indexName, string desc, string keys ) : IndexSchema
indexName string The name of the index
desc string The description of the index
keys string Key columns that are part of the index.
Результат SQLiteConversionEngine.ConversionData.IndexSchema

BuildSQLiteInsert() защищенный статический Метод

Creates a command object needed to insert values into a specific SQLite table.
protected static BuildSQLiteInsert ( TableSchema ts ) : SQLiteCommand
ts SQLiteConversionEngine.ConversionData.TableSchema The table schema object for the table.
Результат System.Data.SQLite.SQLiteCommand

BuildSQLiteUpdate() защищенный статический Метод

Creates a command object needed to insert values into a specific SQLite table.
protected static BuildSQLiteUpdate ( TableSchema ts ) : SQLiteCommand
ts SQLiteConversionEngine.ConversionData.TableSchema The table schema object for the table.
Результат System.Data.SQLite.SQLiteCommand

BuildSourceTableQuery() защищенный абстрактный Метод

Builds a SELECT query for a specific table. Needed in the process of copying rows from the SQL Server database to the SQLite database.
protected abstract BuildSourceTableQuery ( TableSchema tableSchema ) : string
tableSchema SQLiteConversionEngine.ConversionData.TableSchema
Результат string

BuildSqlServerInsert() защищенный статический Метод

Creates a command object needed to insert values into a specific SQLite table.
protected static BuildSqlServerInsert ( TableSchema ts ) : SqlCommand
ts SQLiteConversionEngine.ConversionData.TableSchema The table schema object for the table.
Результат System.Data.SqlClient.SqlCommand

CancelConversion() публичный Метод

Cancels the conversion.
public CancelConversion ( ) : void
Результат void

CastValueForColumn() защищенный статический Метод

Used in order to adjust the value received from SQL Servr for the SQLite database.
protected static CastValueForColumn ( object val, ColumnSchema columnSchema ) : object
val object The value object
columnSchema ColumnSchema The corresponding column schema
Результат object

CheckCancelled() защищенный статический Метод

Convenience method for checking if the conversion progress needs to be cancelled.
protected static CheckCancelled ( ) : void
Результат void

ConvertSourceDatabaseToDestination() защищенный абстрактный Метод

Do the entire process of first reading the SQL Server schema, creating a corresponding SQLite schema, and copying all rows from the SQL Server database to the SQLite database.
protected abstract ConvertSourceDatabaseToDestination ( SqlConnection sqlConnection, SQLiteConnection sqliteConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void
sqlConnection System.Data.SqlClient.SqlConnection The SQL connection.
sqliteConnection System.Data.SQLite.SQLiteConnection The SQLite connection.
sqlConversionHandler SqlConversionHandler The SQL conversion handler.
sqlTableSelectionHandler SqlTableSelectionHandler The SQL table selection handler.
failedViewDefinitionHandler FailedViewDefinitionHandler The failed view definition handler.
createTriggers bool if set to true [create triggers].
Результат void

ConvertToDatabase() публичный абстрактный Метод

This method takes as input the connection to an SQL Server database and creates a corresponding SQLite database file with a schema derived from the SQL Server database.
The method continues asynchronously in the background and the caller returned immediatly.
public abstract ConvertToDatabase ( SqlConnection sqlConnection, SQLiteConnection sqliteConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void
sqlConnection System.Data.SqlClient.SqlConnection The SQL connection.
sqliteConnection System.Data.SQLite.SQLiteConnection The SQLite connection.
sqlConversionHandler SqlConversionHandler The SQL conversion handler.
sqlTableSelectionHandler SqlTableSelectionHandler The SQL table selection handler.
failedViewDefinitionHandler FailedViewDefinitionHandler The failed view definition handler.
createTriggers bool if set to true [create triggers].
Результат void

ConvertToDatabase() публичный абстрактный Метод

This method takes as input the connection string to an SQL Server database and creates a corresponding SQLite database file with a schema derived from the SQL Server database.
The method continues asynchronously in the background and the caller returned immediatly.
public abstract ConvertToDatabase ( string sqlServerConnectionString, SQLiteConnection sqliteConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void
sqlServerConnectionString string The connection string to the SQL Server database.
sqliteConnection System.Data.SQLite.SQLiteConnection The path to the SQLite database file that needs to get created.
sqlConversionHandler SqlConversionHandler The SQL conversion handler.
sqlTableSelectionHandler SqlTableSelectionHandler The SQL table selection handler.
failedViewDefinitionHandler FailedViewDefinitionHandler The failed view definition handler.
createTriggers bool if set to true [create triggers].
Результат void

ConvertToDatabase() публичный абстрактный Метод

This method takes as input the connection string to an SQL Server database and creates a corresponding SQLite database file with a schema derived from the SQL Server database.
The method continues asynchronously in the background and the caller returned immediatly.
public abstract ConvertToDatabase ( string sqlServerConnectionString, string sqliteConnectionString, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler, FailedViewDefinitionHandler failedViewDefinitionHandler, bool createTriggers ) : void
sqlServerConnectionString string The connection string to the SQL Server database.
sqliteConnectionString string The connection string to the SQLite database.
sqlConversionHandler SqlConversionHandler The SQL conversion handler.
sqlTableSelectionHandler SqlTableSelectionHandler
failedViewDefinitionHandler FailedViewDefinitionHandler The failed view definition handler.
createTriggers bool if set to true [create triggers].
Результат void

CopySourceDatabaseRowsToDestination() защищенный абстрактный Метод

Copies table rows from the SQL Server database to the SQLite database.
protected abstract CopySourceDatabaseRowsToDestination ( SqlConnection sqlConnection, SQLiteConnection sqliteConnection, List schema, SqlConversionHandler handler ) : void
sqlConnection System.Data.SqlClient.SqlConnection The SQL connection.
sqliteConnection System.Data.SQLite.SQLiteConnection The SQLite connection.
schema List The schema of the SQL Server database.
handler SqlConversionHandler A handler to handle progress notifications.
Результат void

CreateForeignKeySchema() защищенный абстрактный Метод

Add foreign key schema object from the specified components (Read from SQL Server).
protected abstract CreateForeignKeySchema ( IDbConnection sourceConnection, TableSchema tableSchema ) : void
sourceConnection IDbConnection
tableSchema SQLiteConversionEngine.ConversionData.TableSchema
Результат void

CreateSQLiteConnectionString() защищенный статический Метод

Creates SQLite connection string from the specified DB file path.
protected static CreateSQLiteConnectionString ( string sqlitePath, string password ) : string
sqlitePath string The path to the SQLite database file.
password string
Результат string

CreateSQLiteDatabase() защищенный статический Метод

Creates the SQLite database.
protected static CreateSQLiteDatabase ( SQLiteConnection sqliteConnection, DatabaseSchema schema, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void
sqliteConnection System.Data.SQLite.SQLiteConnection The SQLite connection.
schema DatabaseSchema The schema.
handler SqlConversionHandler The handler.
viewFailureHandler FailedViewDefinitionHandler The view failure handler.
Результат void

CreateSQLiteDatabase() защищенный статический Метод

Creates the SQLite database from the schema read from the SQL Server.
protected static CreateSQLiteDatabase ( string sqlitePath, DatabaseSchema schema, string password, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void
sqlitePath string The path to the generated DB file.
schema DatabaseSchema The schema of the SQL server database.
password string The password to use for encrypting the DB or null if non is needed.
handler SqlConversionHandler A handle for progress notifications.
viewFailureHandler FailedViewDefinitionHandler
Результат void

CreateSqlServerConnectionString() защищенный статический Метод

Creates SQLite connection string from the specified DB file path.
protected static CreateSqlServerConnectionString ( string sqlitePath, string password ) : string
sqlitePath string The path to the SQLite database file.
password string
Результат string

CreateSqlServerDatabase() защищенный статический Метод

Creates the SQLite database.
protected static CreateSqlServerDatabase ( SQLiteConnection sqliteConnection, DatabaseSchema schema, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void
sqliteConnection System.Data.SQLite.SQLiteConnection The SQLite connection.
schema DatabaseSchema The schema.
handler SqlConversionHandler The handler.
viewFailureHandler FailedViewDefinitionHandler The view failure handler.
Результат void

CreateSqlServerDatabase() защищенный статический Метод

Creates the SQLite database from the schema read from the SQL Server.
protected static CreateSqlServerDatabase ( string sqlitePath, DatabaseSchema schema, string password, SqlConversionHandler handler, FailedViewDefinitionHandler viewFailureHandler ) : void
sqlitePath string The path to the generated DB file.
schema DatabaseSchema The schema of the SQL server database.
password string The password to use for encrypting the DB or null if non is needed.
handler SqlConversionHandler A handle for progress notifications.
viewFailureHandler FailedViewDefinitionHandler
Результат void

CreateTableSchema() защищенный абстрактный Метод

Creates a TableSchema object using the specified SQL Server connection and the name of the table for which we need to create the schema.
protected abstract CreateTableSchema ( IDbConnection sourceConnection, string tableName, string tableSchemaName ) : TableSchema
sourceConnection IDbConnection
tableName string The name of the table for which we wants to create the table schema.
tableSchemaName string
Результат SQLiteConversionEngine.ConversionData.TableSchema

FixDefaultValueString() защищенный статический Метод

Does some necessary adjustments to a value string that appears in a column DEFAULT clause.
protected static FixDefaultValueString ( string colDefault ) : string
colDefault string The original default value string (as read from SQL Server).
Результат string

GetDbTypeOfColumn() защищенный статический Метод

Matches SQL Server types to general DB types
protected static GetDbTypeOfColumn ( ColumnSchema columnSchema ) : DbType
columnSchema ColumnSchema The column schema to use for the match
Результат DbType

GetNormalizedName() защищенный статический Метод

Used in order to avoid breaking naming rules (e.g., when a table has a name in SQL Server that cannot be used as a basis for a matching index name in SQLite).
protected static GetNormalizedName ( string str, List names ) : string
str string The name to change if necessary
names List Used to avoid duplicate names
Результат string

InitializeSQLiteConnection() публичный Метод

public InitializeSQLiteConnection ( string sqliteConnectionString ) : SQLiteConnection
sqliteConnectionString string
Результат System.Data.SQLite.SQLiteConnection

InitializeSQLiteDatabase() публичный Метод

public InitializeSQLiteDatabase ( SQLiteConnection sqliteConnection, List PragmaCommands ) : void
sqliteConnection System.Data.SQLite.SQLiteConnection
PragmaCommands List
Результат void

InitializeSqlServerConnection() публичный Метод

public InitializeSqlServerConnection ( string sqlServerConnectionString ) : SqlConnection
sqlServerConnectionString string
Результат System.Data.SqlClient.SqlConnection

InitializeSqlServerDatabase() публичный Метод

public InitializeSqlServerDatabase ( SqlConnection sqlConnection ) : void
sqlConnection System.Data.SqlClient.SqlConnection
Результат void

ParseBlobAsGuid() защищенный статический Метод

protected static ParseBlobAsGuid ( byte blob ) : System.Guid
blob byte
Результат System.Guid

ParseStringAsGuid() защищенный статический Метод

protected static ParseStringAsGuid ( string str ) : System.Guid
str string
Результат System.Guid

ReadSourceSchema() защищенный абстрактный Метод

Reads the entire SQL Server DB schema using the specified connection string.
protected abstract ReadSourceSchema ( SqlConnection sqlConnection, SqlConversionHandler sqlConversionHandler, SqlTableSelectionHandler sqlTableSelectionHandler ) : DatabaseSchema
sqlConnection System.Data.SqlClient.SqlConnection The SQL connection.
sqlConversionHandler SqlConversionHandler The SQL conversion handler.
sqlTableSelectionHandler SqlTableSelectionHandler The SQL table selection handler.
Результат DatabaseSchema

ValidateDataType() защищенный статический Метод

Small validation method to make sure we don't miss anything without getting an exception.
protected static ValidateDataType ( string dataType ) : void
dataType string The datatype to validate.
Результат void

WriteTriggerSchema() защищенный статический Метод

Gets a create script for the triggerSchema in SQLite syntax
protected static WriteTriggerSchema ( TriggerSchema ts ) : string
ts TriggerSchema Trigger to script
Результат string

Описание свойств

_cancelled защищенное статическое свойство

protected static bool _cancelled
Результат bool

_defaultValueRx защищенное статическое свойство

protected static Regex,System.Text.RegularExpressions _defaultValueRx
Результат System.Text.RegularExpressions.Regex

_isActive защищенное статическое свойство

protected static bool _isActive
Результат bool

_keyRx защищенное статическое свойство

protected static Regex,System.Text.RegularExpressions _keyRx
Результат System.Text.RegularExpressions.Regex