internal bool HaveValuesChanged(DataColumn[] columns, DataRowVersion version1, DataRowVersion version2) { for (int i = 0; i < columns.Length; i++) { CheckColumn(columns[i]); } DataKey key = new DataKey(columns, false); // temporary key, don't copy columns return HasKeyChanged(key, version1, version2); }
internal override void CheckConstraint(DataRow row, DataRowAction action) { if (Table.EnforceConstraints && (action == DataRowAction.Add || action == DataRowAction.Change || (action == DataRowAction.Rollback && row.tempRecord != -1))) { if (row.HaveValuesChanged(Columns)) { Index index = Key.GetSortIndex(); object[] values = row.GetColumnValues(Columns); if (index.IsKeyInIndex(values)) { #if DEBUG if (CompModSwitches.Data_Constraints.TraceVerbose) { Debug.WriteLine("UniqueConstraint violation..."); string valuesText = ""; for (int i = 0; i < values.Length; i++) { valuesText = Convert.ToString(values[i]) + (i < values.Length - 1 ? ", " : ""); } Debug.WriteLine(" constraint: " + this.GetDebugString()); Debug.WriteLine(" key values: " + valuesText); Range range = index.FindRecords(values); int record = index.GetRecord(range.Min); Debug.WriteLine(" conflicting record: " + record.ToString()); } #endif throw ExceptionBuilder.ConstraintViolation(Columns, values); } } } }