public Tester() { InitializeComponent(); //Test t = new Test(); KeyMap km = new KeyMap(); IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(@"c:\tmp\MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, km); stream.Close(); }
// Need to tell which sides are being passed. public void CompareTables(Side side1, Side side2, KeyMap km) { this._TotalOuterRecords = 0; this._TotalUnmatched = 0; //Should grab empty select DataRow[] OuterRows = side1.Table.Select(); this._TotalOuterRecords = OuterRows.Length; //Traverse Outer Table And Compare rows by the keys foreach (DataRow OuterRow in OuterRows) { //Check for items in InnerRow.col = OuterRow.value //Figure out if OuterRow is Side1 or Side2 //SideEnum whichSide = Utility.Lookup.LookupSideEnum(OuterRow.Table.ExtendedProperties["Side"].ToString()); //Declare a side object with rows to build the expression. Side side = new Side(OuterRow, side1.SideEnum); string exp = km.getExpression(side); DataRow[] InnerRows = side2.Table.Select(exp); //Found Match On Key if (InnerRows.Length > 0) { //One to one Match if (InnerRows.Length == 1) { InnerRows[0]["FK"] = OuterRow["RowId"]; OuterRow["MatchCount"] = 1; RaiseMatchEvent(OuterRow, InnerRows); } else //Many to One { if (Config.AllowOneToMany) { RaiseMatchEvent(OuterRow, InnerRows); OuterRow["MatchCount"] = InnerRows.Length; foreach (DataRow InnerRow in InnerRows) { //AddToDiffTable(OuterRow, InnerRow); //Points each Inner Row Foreign Key to the Outer Row ID //Need a way to flag the rows that have one to many.. InnerRow["FK"] = OuterRow["RowId"]; } } else { //Process Unmatched.. Flag as Many to One } } System.Diagnostics.Debug.WriteLine("Found Item" + OuterRow[0].ToString()); } //Not Found else { //Process Unmatched OuterRow this._TotalUnmatched++; } } }
public void CompareTablesMine(Side side1, Side side2, KeyMap km) { //Run Compare Tables twice, to go both ways of finding the matches. //base.CompareTables(side1.Table, side2.Table, new KeyMap()); //base.CompareTables(side2.Table, side1.Table, new KeyMap()); //Need to come up with Diffs algorithm this.CalcDiffs(); }