Пример #1
0
        public static RowDataCompareResult Compare(TableDefinition tableDefinition, SnapshotRowKey snapshotRowKey,
                                                   SnapshotRow beforeRow, SnapshotRow afterRow)
        {
            var result = true;

            var nonKeyFieldNames = beforeRow.GetFieldNames()
                                   .Concat(afterRow.GetFieldNames())
                                   .Distinct()
                                   .Except(snapshotRowKey.GetFieldNames().Concat(tableDefinition.ExcludedColumns))
                                   .ToList();

            var diffs = new List <FieldDifference>();

            foreach (var fieldName in nonKeyFieldNames)
            {
                var before        = beforeRow.GetField(fieldName);
                var after         = afterRow.GetField(fieldName);
                var compareResult = ValueComparer.Compare(before, after);
                if (compareResult != 0)
                {
                    diffs.Add(new FieldDifference(fieldName, before, after));
                    result = false;
                }
            }

            return(new RowDataCompareResult(result, diffs, beforeRow, afterRow));
        }
Пример #2
0
        public SnapshotRow GetRow(SnapshotRowKey key, string tableName)
        {
            if (!_tables.TryGetValue(tableName, out var snapshotTable))
            {
                return(null);
            }

            return(snapshotTable.Rows.SingleOrDefault(r => Equals(new SnapshotRowKey(r, snapshotTable.TableDefinition), key)));
        }