ITWorx.ComparerLibrary
1.0.3
dotnet add package ITWorx.ComparerLibrary --version 1.0.3
NuGet\Install-Package ITWorx.ComparerLibrary -Version 1.0.3
<PackageReference Include="ITWorx.ComparerLibrary" Version="1.0.3" />
paket add ITWorx.ComparerLibrary --version 1.0.3
#r "nuget: ITWorx.ComparerLibrary, 1.0.3"
// Install ITWorx.ComparerLibrary as a Cake Addin #addin nuget:?package=ITWorx.ComparerLibrary&version=1.0.3 // Install ITWorx.ComparerLibrary as a Cake Tool #tool nuget:?package=ITWorx.ComparerLibrary&version=1.0.3
first of all, you can find the comparer library code here https://github.com/BotrosMaqar/ComparerLibrary. Comparer library compares two objects and returns differences as the below Comparer library contains 2 main functions Compare that accepts ComparerSettingDTO object here is a sample of how you can use it Comparer comparer = new Comparer(); List<ComparisonResult> comparisonResults = new List<ComparisonResult>(); ComparerSettingDTO comparerSettingDTO = new ComparerSettingDTO(); List<string> activitiesUniqueKeys = new List<string>() { "AcIdentifier", "CaIdentifier" }; Dictionary<string, List<string>> uniqueKeysToCompare = new Dictionary<string, List<string>>(); uniqueKeysToCompare.Add("Activities", activitiesUniqueKeys); comparerSettingDTO.PropsToExcludeFromComparison = new List<string>() { "Id", "ReuploadToSmc", "LastChangedDate","CreatedDate", "IsMigrated" }; comparerSettingDTO.CompareCollectionsInMainObjectOnly = true; comparerSettingDTO.CompareCollectionUsingTheirIndexes = false; comparerSettingDTO.UniqueKeysToCompare = uniqueKeysToCompare; comparerSettingDTO.SourceObject = demandPlanComparisonDTO.SourceJsonDemands; comparerSettingDTO.DestinationObject = demandPlanComparisonDTO.DestinationDBDemands; comparisonResults = comparer.Compare(comparerSettingDTO);
after this, you can loop on comparisonResult as below for (int diffIndex = 0; diffIndex < comparisonResults.Count; diffIndex++) { if (comparisonResults[diffIndex].HasCountDifference) { differences.Append('\n'); differences.Append("There is a Difference in count between DB and Json in TableName: " + comparisonResults[diffIndex].TableName + " DBCount: " + comparisonResults[diffIndex].DestinationCount
" JsonCount: " + comparisonResults[diffIndex].SourceCount); } else { if (!string.IsNullOrWhiteSpace(comparisonResults[diffIndex].CustomError)) { differences.AppendLine(); differences.Append("TableName: " + comparisonResults[diffIndex].TableName +":" ); differences.Append(" Custom error is " + comparisonResults[diffIndex].CustomError); } else { differences.Append('\n'); differences.Append("TableName: " + comparisonResults[diffIndex].TableName + " PropertyName: " + comparisonResults[diffIndex].PropertyName " JsonValue: " + comparisonResults[diffIndex].SourceValue + " DBValue: " + comparisonResults[diffIndex].DestinationValue); } } } return differences.ToString(); waiting you feedback Thanks, Botros
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.3 | 412 | 4/20/2021 |