Esempio n. 1
0
        /// <summary>
        /// Get clone object of current DataTable
        /// </summary>
        /// <returns>Clone object of current DataTable</returns>
        public DataTable Clone()
        {
            var dataTable = new DataTable();

            foreach (var dr in Rows)
                dataTable.Add(dr.Clone());

            return dataTable;
        }
Esempio n. 2
0
        /// <summary>
        /// Get list of Extra DataRows. DataRows from withTable that don't present in wathTable (just by unique values)
        /// </summary>
        /// <param name="whatTable">What DataTable</param>
        /// <param name="withTable">With what DataTable</param>
        /// <returns>List of Extra DataRows</returns>
        public List<DataRow> TableGetExtraRows(DataTable whatTable, DataTable withTable)
        {
            var extra = new List<DataRow>();

            foreach (var wir in withTable.Rows)
            {
                if (TableFindSimmilarRow(wir, whatTable) == null)
                    extra.Add(wir);
            }

            return extra;
        }
Esempio n. 3
0
        /// <summary>
        /// Get list of Missed DataRows. DataRows from whatTable that don't present in withTable (just by unique values)
        /// </summary>
        /// <param name="whatTable">What DataTable</param>
        /// <param name="withTable">With what DataTable</param>
        /// <returns>List of Missed DataRows</returns>
        public List<DataRow> TableGetMissedRows(DataTable whatTable, DataTable withTable)
        {
            var missed = new List<DataRow>();

            foreach (var war in whatTable.Rows)
            {
                if (TableFindSimmilarRow(war, withTable) == null)
                    missed.Add(war);
            }

            return missed;
        }
Esempio n. 4
0
        /// <summary>
        /// Get list of DataTableDiff objects.
        /// </summary>
        /// <param name="whatTable">What DataTable</param>
        /// <param name="withTable">With what DataTable</param>
        /// <returns>List of DataTableDiff objects. Contains rows with the same uniques but different any other column values</returns>
        public List<DataTableDiff> TableGetDiffRows(DataTable whatTable, DataTable withTable)
        {
            var diffs = new List<DataTableDiff>();

            foreach (var war in whatTable.Rows)
            {
                var wir = TableFindSimmilarRow(war, withTable);
                if (wir != null)
                {
                    if (!RowCompareDataRows(war, wir))
                        diffs.Add(new DataTableDiff { ExpectRow = war, ActualRow = wir });
                }
            }
            return diffs;
        }
Esempio n. 5
0
 /// <summary>
 /// Compare two tables by searching similar rows.
 /// </summary>
 /// <param name="whatTable">What DataTable</param>
 /// <param name="withTable">With what DataTable</param>
 /// <returns>True if all DataRows from whatTable present in withTable (JUST has the same unique column values)</returns>
 public bool TableCompareWithTable(DataTable whatTable, DataTable withTable)
 {
     foreach (var war in whatTable.Rows)
     {
         if (TableFindSimmilarRow(war, withTable) == null)
             return false;
     }
     return true;
 }
Esempio n. 6
0
 /// <summary>
 /// Search simmilar (bu unique column values) DataRow in specified table
 /// </summary>
 /// <param name="whatRow">What DataRow</param>
 /// <param name="whereTable">In what DataTable</param>
 /// <returns>DataRow with the same unique field values</returns>
 public DataRow TableFindSimmilarRow(DataRow whatRow, DataTable whereTable)
 {
     foreach (var row in whereTable.Rows)
     {
         if (RowIsUniqsSame(whatRow, row))
             return row;
     }
     return null;
 }