private TableCell CreateCell(Key key, Column column, Dictionary <Key, Dictionary <string, object> > aList, Dictionary <Key, Dictionary <string, object> > bList, CompareResult compareResult) { var td = new TableCell { CssClass = "_" + column.Name + " " + compareResult }; switch (compareResult) { case CompareResult.NotFoundInA: td.Controls.AddLiteral(GetValueString(bList[key][column.Name], column.DataType)); break; case CompareResult.NotFoundInB: td.Controls.AddLiteral(GetValueString(aList[key][column.Name], column.DataType)); break; case CompareResult.NotEqual: var aValue = aList[key][column.Name]; var bValue = bList[key][column.Name]; if (!TableComparer.ObjectsEqual(aValue, bValue)) { var p1 = new HtmlGenericControl("p"); p1.Attributes["class"] = "OldValue"; p1.Controls.AddLiteral(GetValueString(bValue, column.DataType)); td.Controls.Add(p1); var p2 = new HtmlGenericControl("p"); p2.Attributes["class"] = "NewValue"; p2.Controls.AddLiteral(GetValueString(aValue, column.DataType)); td.Controls.Add(p2); } else { td.Controls.AddLiteral(GetValueString(aValue, column.DataType)); } break; default: break; } return(td); }
private static void FillUpdate(RowComparisonResult change, DetailedTableComparisonResult result, Script script) { var rowA = result.TableA[change.Key]; var rowB = result.TableB[change.Key]; script.AddScript(string.Format("UPDATE [{0}].[{1}] SET\r\n", result.SchemaName, result.TableName)); var comma = ""; foreach (var column in result.Columns.Except(result.PrimaryKey.Columns)) { var columnName = column.Name; var aValue = rowA[columnName]; var bValue = rowB[columnName]; if (!TableComparer.ObjectsEqual(aValue, bValue)) { script.AddToken(comma); script.AddScript(string.Format("[{0}] = {1}", columnName, DataAccess.GetDatabaseValue(aValue, column.DataType))); comma = ",\r\n"; } } script.AddToken("\r\n WHERE"); script.AddScript(GetPrimaryKeyCondition(change, result)); }