public static object[][] getGroups(DataTable table, string[] colsArr) { List <object[]> list = new List <object[]>(); DataColumn[] colsObj = new DataColumn[colsArr.Length]; for (int i = 0; i < colsArr.Length; ++i) { colsObj[i] = table.Columns[colsArr[i]]; } foreach (DataRow row in table.Rows) { object[] curValues = ToolRow.copyRowToArr(colsObj, row); foreach (object[] arr in list) { if (ToolArray.isEqual(arr, curValues)) { curValues = null; break; } } if (curValues != null) { list.Add(curValues); } } list.Sort(new ToolArray.Comparer()); return(list.ToArray()); }
private static bool hasRow(DataTable table, DataRow row) { DataRow rowS = null; if (table != null && row != null && table.PrimaryKey != null && table.PrimaryKey.Length > 0) { object[] arr = ToolRow.copyRowToArr(table.PrimaryKey, row); rowS = table.Rows.Find(arr); } return(rowS != null); }
static object[] compareData(DataRow row, DataColumn[] cols, object[] values) { bool sameData = true; object[] curValues = ToolRow.copyRowToArr(cols, row); for (int i = 0; i < curValues.Length; ++i) { if (!ToolType.isEqual(curValues[i], values[i])) { sameData = false; break; } } return(sameData ? null : curValues); }