From 49537b18e73e9b52cbc3c41eae28c209b98d6bb7 Mon Sep 17 00:00:00 2001 From: RohitM-IN Date: Sat, 3 Feb 2024 18:06:30 +0530 Subject: [PATCH 1/3] removed IDataContract Interface dependency --- src/Comparer/PropertyEqualityComparer.cs | 3 +-- src/DataContract/Result.cs | 2 +- src/Fetcher/DataContractFetcher.cs | 6 ++---- src/Helper/DataContractMismatchIdentifier.cs | 11 ++++------- src/SqlBuilder/QueryBuilder.cs | 3 +-- src/Synchronization.cs | 2 +- 6 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Comparer/PropertyEqualityComparer.cs b/src/Comparer/PropertyEqualityComparer.cs index a19342d..624c479 100644 --- a/src/Comparer/PropertyEqualityComparer.cs +++ b/src/Comparer/PropertyEqualityComparer.cs @@ -6,8 +6,7 @@ namespace DbSyncKit.Core.Comparer /// /// Compares instances of data contracts based on specified properties, which can be either key or comparable properties. /// - /// Type of the data contract implementing . - public class PropertyEqualityComparer : IEqualityComparer where T : IDataContract + public class PropertyEqualityComparer : IEqualityComparer { /// /// Gets the array of objects representing properties used for equality comparison. diff --git a/src/DataContract/Result.cs b/src/DataContract/Result.cs index 16b16e3..38ed7ea 100644 --- a/src/DataContract/Result.cs +++ b/src/DataContract/Result.cs @@ -7,7 +7,7 @@ namespace DbSyncKit.Core.DataContract /// Represents the result of a synchronization operation for a specific data type. /// /// The type of data being synchronized. - public class Result where T : IDataContract + public class Result { /// /// Gets or sets the list of entities that were added during synchronization. diff --git a/src/Fetcher/DataContractFetcher.cs b/src/Fetcher/DataContractFetcher.cs index 1306796..04ac405 100644 --- a/src/Fetcher/DataContractFetcher.cs +++ b/src/Fetcher/DataContractFetcher.cs @@ -46,7 +46,6 @@ public DataContractFetcher(QueryGeneratorFactory factory) /// /// Retrieves data from source and destination databases for a specified table and column list, using a specified data contract type. /// - /// The type of data entities implementing the interface. /// The source database. /// The destination database. /// The name of the table from which to retrieve data. @@ -65,7 +64,7 @@ public void RetrieveDataFromDatabases( List ColumnList, PropertyEqualityComparer ComparablePropertyEqualityComparer, out HashSet sourceList, - out HashSet destinationList) where T : IDataContract + out HashSet destinationList) { var sourceQueryGenerationManager = new QueryGenerationManager(Factory.GetQueryGenerator(source.Provider)); sourceList = GetDataFromDatabase(tableName, source, sourceQueryGenerationManager, ColumnList, ComparablePropertyEqualityComparer); @@ -86,7 +85,6 @@ public void RetrieveDataFromDatabases( /// /// Retrieves data from a database for a specified table, columns, and data contract type. /// - /// The type of data entities implementing the interface. /// The name of the table from which to retrieve data. /// The database connection. /// The query generation manager for creating the SELECT query. @@ -104,7 +102,7 @@ public HashSet GetDataFromDatabase( IDatabase connection, IQueryGenerator manager, List columns, - PropertyEqualityComparer ComparablePropertyEqualityComparer) where T : IDataContract + PropertyEqualityComparer ComparablePropertyEqualityComparer) { var query = manager.GenerateSelectQuery(tableName, columns, string.Empty); diff --git a/src/Helper/DataContractMismatchIdentifier.cs b/src/Helper/DataContractMismatchIdentifier.cs index 4c2f30e..e39bf2a 100644 --- a/src/Helper/DataContractMismatchIdentifier.cs +++ b/src/Helper/DataContractMismatchIdentifier.cs @@ -16,7 +16,6 @@ public class DataContractMismatchIdentifier /// /// Compares two sets of data entities and identifies the added, deleted, and edited entries. /// - /// The type of data entities implementing the interface. /// The source set of data entities. /// The destination set of data entities. /// An equality comparer for identifying key properties. @@ -32,7 +31,7 @@ public Result GetDifferences( HashSet destinationList, PropertyEqualityComparer keyComparer, PropertyEqualityComparer CompariablePropertyComparer, - bool DetailedComparison = true) where T : IDataContract + bool DetailedComparison = true) { var result = new Result(); @@ -67,7 +66,6 @@ public Result GetDifferences( /// /// Determines the overall change type based on the presence of added, edited, and deleted entities in the synchronization . /// - /// The type of data entities implementing the interface. /// The synchronization containing information about added, edited, and deleted entities. /// Specifies whether to consider detailed property changes for edited entities. Default is true. /// @@ -96,7 +94,7 @@ public Result GetDifferences( /// /// /// - public ChangeType DetermineChangeType(Result result, bool DetailedComparison) where T : IDataContract + public ChangeType DetermineChangeType(Result result, bool DetailedComparison) { // Tuple representing combinations of hasAdded, hasEdited, and hasDeleted (bool, bool, bool) key; @@ -146,7 +144,6 @@ public ChangeType DetermineChangeType(Result result, bool DetailedComparis /// /// Identifies edited entries between two sets of data entities by comparing properties. /// - /// The type of data entities implementing the IDataContract interface. /// A set of data entities added to the destination set. /// A set of data entities removed from the destination set. /// An equality comparer for identifying key properties. @@ -159,7 +156,7 @@ public ChangeType DetermineChangeType(Result result, bool DetailedComparis HashSet Added, HashSet Removed, PropertyEqualityComparer keyComparer, - PropertyEqualityComparer CompariablePropertyComparer) where T : IDataContract + PropertyEqualityComparer CompariablePropertyComparer) { List<(T edit, (string propName, object propValue)[] updatedProperties)> edited = new(); @@ -192,7 +189,7 @@ public ChangeType DetermineChangeType(Result result, bool DetailedComparis /// The entity for which the composite key is generated. /// The properties used to create the composite key. /// A string representing the composite key. - private string GenerateCompositeKey(T dataContract, PropertyInfo[] keyProperties) where T : IDataContract + private string GenerateCompositeKey(T dataContract, PropertyInfo[] keyProperties) { var values = new string[keyProperties.Length]; diff --git a/src/SqlBuilder/QueryBuilder.cs b/src/SqlBuilder/QueryBuilder.cs index 36d1dc4..7e2b1ec 100644 --- a/src/SqlBuilder/QueryBuilder.cs +++ b/src/SqlBuilder/QueryBuilder.cs @@ -21,7 +21,6 @@ public class QueryBuilder: QueryHelper /// /// Generates SQL queries for synchronizing data based on the provided object. /// - /// The type of data entities implementing the interface. /// The object containing added, deleted, and edited entries. /// The instance used for generating SQL queries. /// The size of query batches. Default is 20. @@ -34,7 +33,7 @@ public class QueryBuilder: QueryHelper /// It uses the specified instance to generate SQL statements. /// The queries are separated into batches using the specified batch size. /// - public string GetSqlQueryForSyncData(Result result, IQueryGenerator QueryGeneratorManager, int BatchSize = 20) where T : IDataContract + public string GetSqlQueryForSyncData(Result result, IQueryGenerator QueryGeneratorManager, int BatchSize = 20) { if (QueryGeneratorManager == null) { diff --git a/src/Synchronization.cs b/src/Synchronization.cs index 7f25a45..5b16e2b 100644 --- a/src/Synchronization.cs +++ b/src/Synchronization.cs @@ -95,7 +95,7 @@ public Synchronization(DataContractFetcher fetcher, QueryBuilder queryBuilder, D /// The destination database. /// Represents Which Direction to compare db /// A result object containing the differences between source and destination data. - public Result SyncData(IDatabase source, IDatabase destination, Direction direction = Direction.SourceToDestination) where T : IDataContract + public Result SyncData(IDatabase source, IDatabase destination, Direction direction = Direction.SourceToDestination) { #region Properties string tableName = GetTableName(); From 7a20ee6bca221680aef1e5e395eb3ba67df50faa Mon Sep 17 00:00:00 2001 From: Rohit Mahajan Date: Thu, 8 Feb 2024 16:38:07 +0530 Subject: [PATCH 2/3] fix Remove IDataContract --- src/Synchronization.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Synchronization.cs b/src/Synchronization.cs index 5b16e2b..c430dfd 100644 --- a/src/Synchronization.cs +++ b/src/Synchronization.cs @@ -90,7 +90,6 @@ public Synchronization(DataContractFetcher fetcher, QueryBuilder queryBuilder, D /// /// Synchronizes data of a specific type between source and destination databases. /// - /// The type of entity that implements IDataContract. /// The source database. /// The destination database. /// Represents Which Direction to compare db From cff29c45b815477e21e7e6548b71b70633431d49 Mon Sep 17 00:00:00 2001 From: Rohit Mahajan Date: Thu, 8 Feb 2024 16:46:13 +0530 Subject: [PATCH 3/3] Update Version --- src/DbSyncKit.Core.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DbSyncKit.Core.csproj b/src/DbSyncKit.Core.csproj index d1c8ae1..f3ba60a 100644 --- a/src/DbSyncKit.Core.csproj +++ b/src/DbSyncKit.Core.csproj @@ -6,9 +6,9 @@ enable True True - 1.2.0.0 - 1.2.0.0 - 1.2.0.0 + 1.2.1.0 + 1.2.1.0 + 1.2.1.0 https://dbsynckit.rohit-mahajan.in/ README.md https://github.com/RohitM-IN/DbSyncKit