diff --git a/src/DbSyncKit.DB.csproj b/src/DbSyncKit.DB.csproj index 47da6ae..469f38e 100644 --- a/src/DbSyncKit.DB.csproj +++ b/src/DbSyncKit.DB.csproj @@ -31,4 +31,8 @@ + + + + diff --git a/src/Factory/QueryGeneratorFactory.cs b/src/Factory/QueryGeneratorFactory.cs index f8a0bc9..c20f012 100644 --- a/src/Factory/QueryGeneratorFactory.cs +++ b/src/Factory/QueryGeneratorFactory.cs @@ -1,5 +1,6 @@ using DbSyncKit.DB.Enum; using DbSyncKit.DB.Interface; +using DbSyncKit.Templates.Interface; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Fetcher/DataContractFetcher.cs b/src/Fetcher/DataContractFetcher.cs index 8405e1f..516be8e 100644 --- a/src/Fetcher/DataContractFetcher.cs +++ b/src/Fetcher/DataContractFetcher.cs @@ -1,6 +1,8 @@ using DbSyncKit.DB.Comparer; using DbSyncKit.DB.Factory; using DbSyncKit.DB.Interface; +using DbSyncKit.Templates; +using DbSyncKit.Templates.Interface; namespace DbSyncKit.DB.Fetcher { diff --git a/src/Interface/IQueryGenerator.cs b/src/Interface/IQueryGenerator.cs deleted file mode 100644 index 5920ed9..0000000 --- a/src/Interface/IQueryGenerator.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace DbSyncKit.DB.Interface -{ - /// - /// Defines methods for generating SQL queries and handling query-related operations. - /// - public interface IQueryGenerator : IDisposable - { - /// - /// Generates a SELECT query for retrieving data from a database table. - /// - /// The name of the database table. - /// The list of columns to be selected. - /// The schema name of the database table. - /// A string representing the generated SELECT query. - string GenerateSelectQuery(string tableName, List ListOfColumns, string schemaName); - - /// - /// Generates an UPDATE query for updating data in a database table. - /// - /// The entity with the updated data. - /// The list of key columns used for updating. - /// The list of columns to be excluded from the update. - /// A dictionary representing the properties and their new values to be updated. - /// A string representing the generated UPDATE query. - string GenerateUpdateQuery(T DataContract, List keyColumns, List excludedColumns, (string propName, object propValue)[] editedProperties); - - /// - /// Generates a DELETE query for deleting data from a database table. - /// - /// The entity representing the data to be deleted. - /// The list of key columns used for deletion. - /// A string representing the generated DELETE query. - string GenerateDeleteQuery(T entity, List keyColumns); - - /// - /// Generates an INSERT query for inserting data into a database table. - /// - /// The entity representing the data to be inserted. - /// The list of key columns used for insertion. - /// The list of columns to be excluded from the insertion. - /// A string representing the generated INSERT query. - string GenerateInsertQuery(T entity, List keyColumns, List excludedColumns); - - /// - /// Generates a SQL comment. - /// - /// The comment text. - /// A string representing the generated comment. - string GenerateComment(string comment); - - /// - /// Gets a condition for use in a SQL WHERE clause based on the entity and key columns. - /// - /// The entity for which the condition is generated. - /// The list of key columns used to create the condition. - /// A string representing the generated condition for a SQL WHERE clause. - List GetCondition(T entity, List keyColumns); - - /// - /// Escapes special characters in the input to make it SQL-safe. - /// - /// The input object or string to be escaped. - /// The escaped object or string. - object? EscapeValue(object? input); - - /// - /// Escapes the input column name to be used safely in SQL queries. - /// - /// The input column name to be escaped. - /// The escaped column name. - string EscapeColumn(string? input); - - /// - /// Generates a SQL batch separator ('GO' statement in SQL Server) used to execute batches of SQL statements. - /// - /// A string representing the generated batch separator. - string GenerateBatchSeparator(); - } -} diff --git a/src/QueryGenerationManager.cs b/src/QueryGenerationManager.cs deleted file mode 100644 index bd0acd5..0000000 --- a/src/QueryGenerationManager.cs +++ /dev/null @@ -1,88 +0,0 @@ -using DbSyncKit.DB.Interface; - -namespace DbSyncKit.DB -{ - /// - /// Manages the generation of SQL queries for data operations by delegating the query generation tasks - /// to an implementation of the interface. - /// - /// - /// This class acts as a wrapper around an instance of and forwards - /// query generation requests to the underlying implementation. - /// - public class QueryGenerationManager : IQueryGenerator - { - private readonly IQueryGenerator _querryGenerator; - - /// - /// The underlying query generator instance used for actual query generation. - /// - public QueryGenerationManager(IQueryGenerator querryGenerator) - { - _querryGenerator = querryGenerator; - } - - #region Public Methods - /// - public string GenerateSelectQuery(string tableName, List listOfColumns, string schemaName) - { - return _querryGenerator.GenerateSelectQuery(tableName, listOfColumns, schemaName); - } - - /// - public string GenerateUpdateQuery(T DataContract, List keyColumns, List excludedColumns, (string propName, object propValue)[] editedProperties) - { - return _querryGenerator.GenerateUpdateQuery(DataContract, keyColumns, excludedColumns, editedProperties); - } - - /// - public string GenerateDeleteQuery(T entity, List keyColumns) - { - return _querryGenerator.GenerateDeleteQuery(entity, keyColumns); - } - - /// - public string GenerateInsertQuery(T entity, List keyColumns, List excludedColumns) - { - return _querryGenerator.GenerateInsertQuery(entity, keyColumns, excludedColumns); - } - - /// - public string GenerateComment(string comment) - { - return _querryGenerator.GenerateComment(comment); - } - - /// - public List GetCondition(T entity, List keyColumns) - { - return _querryGenerator.GetCondition(entity, keyColumns); - } - - /// - public object? EscapeValue(object? input) - { - return _querryGenerator.EscapeValue(input); - } - - /// - public string EscapeColumn(string? input) - { - return _querryGenerator.EscapeColumn(input); - } - - /// - public string GenerateBatchSeparator() - { - return _querryGenerator.GenerateBatchSeparator(); - } - - /// - public void Dispose() - { - _querryGenerator.Dispose(); - } - - #endregion - } -}