private static FieldDifference SubstituteField(TableDefinition table, FieldDifference fieldDifference, List <SubstituteValues> substituteValues)
        {
            var subs = GetColumnSubstitutions(table, fieldDifference, substituteValues)
                       ?? GetReferencedColumnSubstitutions(table, fieldDifference, substituteValues);

            if (subs == null)
            {
                return(fieldDifference);
            }

            return(new FieldDifference(fieldDifference.Name, SubstituteValue(fieldDifference.Before, subs.Substitutes), SubstituteValue(fieldDifference.After, subs.Substitutes)));
        }
        private static SubstituteValues GetReferencedColumnSubstitutions(TableDefinition table, FieldDifference fieldDifference, List <SubstituteValues> substituteValues)
        {
            var col = table.Columns.FirstOrDefault(c => c.Name == fieldDifference.Name &&
                                                   c.ReferencedTableName != null &&
                                                   c.ReferencedPropertyName != null);

            if (col == null)
            {
                return(null);
            }
            return(substituteValues.SingleOrDefault(sv => sv.ColumnValueSet.Table.TableName == col.ReferencedTableName &&
                                                    sv.ColumnValueSet.Column.Name == col.ReferencedPropertyName));
        }
 private static SubstituteValues GetColumnSubstitutions(TableDefinition table, FieldDifference fieldDifference, List <SubstituteValues> substituteValues)
 {
     return(substituteValues.SingleOrDefault(sv => sv.ColumnValueSet.Table.TableName == table.TableName &&
                                             sv.ColumnValueSet.Column.Name == fieldDifference.Name));
 }