diff --git a/src/DatabaseManager.cs b/src/DatabaseManager.cs index 92a2d04..afe7067 100644 --- a/src/DatabaseManager.cs +++ b/src/DatabaseManager.cs @@ -28,7 +28,7 @@ public DatabaseManager(T databaseProvider) /// The SQL query to execute. /// The name of the table associated with the query. /// A list of results of type . - public List ExecuteQuery(string query, string tableName) where TItem : IDataContract + public List ExecuteQuery(string query, string tableName) { List result = new List(); diff --git a/src/Extensions/DataRowExtensions.cs b/src/Extensions/DataRowExtensions.cs index 03401fe..efb4499 100644 --- a/src/Extensions/DataRowExtensions.cs +++ b/src/Extensions/DataRowExtensions.cs @@ -14,9 +14,6 @@ public static class DataRowExtensions /// The DataRow from which to retrieve the value. /// The name of the column. /// The value of the specified column, converted to the specified type. - /// - /// This extension method is intended for use with classes that inherit from . - /// public static T GetValue(this DataRow row, string columnName) { // Check if the DataRow is null diff --git a/src/Helper/QueryHelper.cs b/src/Helper/QueryHelper.cs index 186e395..6bff04e 100644 --- a/src/Helper/QueryHelper.cs +++ b/src/Helper/QueryHelper.cs @@ -12,9 +12,9 @@ public class QueryHelper /// /// Gets the table name of a specified type, considering the TableNameAttribute if present. /// - /// The type for which to get the table name. Must implement . + /// The type for which to get the table name. /// The table name. - public string GetTableName() where T : IDataContract + public string GetTableName() { return CacheManager.GetTableName(typeof(T)); } @@ -22,9 +22,9 @@ public string GetTableName() where T : IDataContract /// /// Gets the table schema of a specified type, considering the TableSchemaAttribute if present. /// - /// The type for which to get the table schema. Must implement . + /// The type for which to get the table schema. /// The table schema name or null if not specified. - public string? GetTableSchema() where T : IDataContract + public string? GetTableSchema() { return CacheManager.GetTableSchema(typeof(T)); } @@ -32,9 +32,9 @@ public string GetTableName() where T : IDataContract /// /// Gets whether the type specifies to generate an INSERT query with ID, considering the GenerateInsertWithIDAttribute if present. /// - /// The type for which to determine the generation of INSERT query with ID. Must implement . + /// The type for which to determine the generation of INSERT query with ID. /// True if the INSERT query should include ID, otherwise false. - public bool GetInsertWithID() where T : IDataContract + public bool GetInsertWithID() { return CacheManager.GetInsertWithID(typeof(T)); } @@ -44,9 +44,9 @@ public bool GetInsertWithID() where T : IDataContract /// during insert query generation, considering the GenerateInsertWithIDAttribute if present. /// /// The type for which to determine the inclusion of identity insert statements. - /// Must implement . + /// /// true if identity insert statements should be included; otherwise, false. - public bool GetIncludeIdentityInsert() where T : IDataContract + public bool GetIncludeIdentityInsert() { return CacheManager.GetIncludeIdentityInsert(typeof(T)); } @@ -54,10 +54,9 @@ public bool GetIncludeIdentityInsert() where T : IDataContract /// /// Gets the names of properties marked as key columns for a specified type. /// - /// The type for which to get the key columns. Must implement . + /// The type for which to get the key columns. /// A list of key column names. - /// - public List GetKeyColumns() where T : IDataContract + public List GetKeyColumns() { return CacheManager.GetKeyColumns(typeof(T)); } @@ -65,10 +64,9 @@ public List GetKeyColumns() where T : IDataContract /// /// Gets the names of properties marked as excluded properties for a specified type. /// - /// The type for which to get the excluded properties. Must implement . + /// The type for which to get the excluded properties. /// A list of excluded property names. - /// - public List GetExcludedColumns() where T : IDataContract + public List GetExcludedColumns() { return CacheManager.GetExcludedColumns(typeof(T)); } @@ -76,10 +74,9 @@ public List GetExcludedColumns() where T : IDataContract /// /// Gets the names of all properties for a specified type. /// - /// The type for which to get all properties. Must implement . + /// The type for which to get all properties. /// A list of all property names. - /// - public List GetAllColumns() where T : IDataContract + public List GetAllColumns() { return CacheManager.GetAllColumns(typeof(T)); } @@ -87,37 +84,33 @@ public List GetAllColumns() where T : IDataContract /// /// Retrieves a list of identity columns for a specified data contract type . /// - /// The type implementing the IDataContract interface. /// A list containing the names of identity columns for the specified data contract type . /// /// This method uses reflection to analyze the properties of the specified type and retrieves properties marked with a [Key] attribute, indicating identity columns. /// - /// - public List GetIdentityColumns() where T : IDataContract + public List GetIdentityColumns() { return CacheManager.GetIdentityColumns(typeof(T)); } /// /// Retrieves an array of objects representing the properties that are used for data comparison - /// in objects of type . These properties are determined based on the implementation of the - /// interface. + /// in objects of type . /// /// The type of objects for which to retrieve comparable properties. /// An array of objects representing the comparable properties of type . - public PropertyInfo[] GetComparableProperties() where T: IDataContract + public PropertyInfo[] GetComparableProperties() { return CacheManager.GetComparableProperties(typeof(T)); } /// /// Retrieves an array of objects representing the properties that are used as key properties - /// for uniquely identifying objects of type . These key properties are determined based on the - /// implementation of the interface. + /// for uniquely identifying objects of type . /// /// The type of objects for which to retrieve key properties. /// An array of objects representing the key properties of type . - public PropertyInfo[] GetKeyProperties() where T : IDataContract + public PropertyInfo[] GetKeyProperties() { return CacheManager.GetKeyProperties(typeof(T)); } diff --git a/src/Interface/IDataContract.cs b/src/Interface/IDataContract.cs deleted file mode 100644 index 38e17e7..0000000 --- a/src/Interface/IDataContract.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace DbSyncKit.DB.Interface -{ - /// - /// Represents an interface for data contracts that require comparison functionality. - /// - /// - /// Implement this interface in data contracts to enable comparison functionality. - /// - public interface IDataContract - { - } -} diff --git a/src/Interface/IQueryGenerator.cs b/src/Interface/IQueryGenerator.cs index b400392..1740aac 100644 --- a/src/Interface/IQueryGenerator.cs +++ b/src/Interface/IQueryGenerator.cs @@ -13,7 +13,7 @@ public interface IQueryGenerator : IDisposable /// 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) where T : IDataContract; + string GenerateSelectQuery(string tableName, List ListOfColumns, string schemaName); /// /// Generates an UPDATE query for updating data in a database table. @@ -24,7 +24,7 @@ public interface IQueryGenerator : IDisposable /// 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) where T : IDataContract; + string GenerateUpdateQuery(T DataContract, List keyColumns, List excludedColumns, (string propName, object propValue)[] editedProperties); /// /// Generates a DELETE query for deleting data from a database table. @@ -33,7 +33,7 @@ public interface IQueryGenerator : IDisposable /// 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) where T : IDataContract; + string GenerateDeleteQuery(T entity, List keyColumns); /// /// Generates an INSERT query for inserting data into a database table. @@ -43,7 +43,7 @@ public interface IQueryGenerator : IDisposable /// 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) where T : IDataContract; + string GenerateInsertQuery(T entity, List keyColumns, List excludedColumns); /// /// Generates a SQL comment. @@ -59,7 +59,7 @@ public interface IQueryGenerator : IDisposable /// 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) where T : IDataContract; + List GetCondition(T entity, List keyColumns); /// /// Escapes special characters in the input to make it SQL-safe. diff --git a/src/QueryGenerationManager.cs b/src/QueryGenerationManager.cs index 9f354e8..bd0acd5 100644 --- a/src/QueryGenerationManager.cs +++ b/src/QueryGenerationManager.cs @@ -24,25 +24,25 @@ public QueryGenerationManager(IQueryGenerator querryGenerator) #region Public Methods /// - public string GenerateSelectQuery(string tableName, List listOfColumns, string schemaName) where T : IDataContract + 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) where T : IDataContract + 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) where T : IDataContract + public string GenerateDeleteQuery(T entity, List keyColumns) { return _querryGenerator.GenerateDeleteQuery(entity, keyColumns); } /// - public string GenerateInsertQuery(T entity, List keyColumns, List excludedColumns) where T : IDataContract + public string GenerateInsertQuery(T entity, List keyColumns, List excludedColumns) { return _querryGenerator.GenerateInsertQuery(entity, keyColumns, excludedColumns); } @@ -54,7 +54,7 @@ public string GenerateComment(string comment) } /// - public List GetCondition(T entity, List keyColumns) where T : IDataContract + public List GetCondition(T entity, List keyColumns) { return _querryGenerator.GetCondition(entity, keyColumns); }