private static RowDifference RequireColumns(RowDifference diff, List <string> requiredColumns) { var missingCols = requiredColumns .Where(col => !diff.Differences?.Differences.Any(d => d.Name == col) ?? true) .ToList(); if (!missingCols.Any()) { return(diff); } var differences = diff.Differences?.Differences?.ToList() ?? new List <FieldDifference>(); FieldDifference MakeAddedColumnDifference(string col) { var value = (diff.Before ?? diff.After)?.GetField(col); return(new FieldDifference(col, value, value)); } differences.AddRange(missingCols.Select(MakeAddedColumnDifference)); var diffResult = new RowDataCompareResult(diff.Differences?.Matched ?? true, differences, diff.Before, diff.After); return(new RowDifference(diff.Key, diffResult, diff.DifferenceType)); }
private static List <FieldDifference> SubstitutedDifferences(TableDefinition table, RowDataCompareResult rowDifferences, List <SubstituteValues> substituteValues) { return(rowDifferences.Differences.Select(fd => SubstituteField(table, fd, substituteValues)).ToList()); }
private static RowDifference SubstituteRowDiffs(TableDefinition table, RowDifference row, List <SubstituteValues> substituteValues) { var compareResult = new RowDataCompareResult(row.Differences.Matched, SubstitutedDifferences(table, row.Differences, substituteValues), row.Before, row.After); return(new RowDifference(row.Key, compareResult, row.DifferenceType)); }