public bool GetNext()
{
Constraint candidate;
_currentObject = null;
while (_tables != null)
{
if (_constraints == null)
{
if (!_tables.MoveNext())
{
_tables = null;
return false;
}
_constraints = ((DataTable)_tables.Current).Constraints.GetEnumerator();
}
if (!_constraints.MoveNext())
{
_constraints = null;
continue;
}
Debug.Assert(_constraints.Current is Constraint, "ConstraintEnumerator, contains object which is not constraint");
candidate = (Constraint)_constraints.Current;
if (IsValidCandidate(candidate))
{
_currentObject = candidate;
return true;
}
}
return false;
}
internal void EnableConstraints() { IntPtr hscp; Bid.ScopeEnter(out hscp, "<ds.DataSet.EnableConstraints|INFO> %d#\n", ObjectID); try { bool errors = false; for (ConstraintEnumerator constraints = new ConstraintEnumerator(this); constraints.GetNext(); ) { Constraint constraint = (Constraint)constraints.GetConstraint(); errors |= constraint.IsConstraintViolated(); } foreach (DataTable table in Tables) { foreach (DataColumn column in table.Columns) { if (!column.AllowDBNull) { errors |= column.IsNotAllowDBNullViolated(); } if (column.MaxLength >= 0) { errors |= column.IsMaxLengthViolated(); } } } if (errors) this.FailedEnableConstraints(); } finally { Bid.ScopeLeave(ref hscp); } }