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.
파일 보기 프로젝트 열기: johnmbaughman/SQLiteConverter

보호된 프로퍼티들

프로퍼티 타입 설명
_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