/// <summary>
/// Clears the collection of all rows.
/// </summary>
public void Clear()
{
if (this.table.DataSet != null && this.table.DataSet.EnforceConstraints)
{
foreach (Constraint c in table.Constraints)
{
UniqueConstraint uc = c as UniqueConstraint;
if (uc == null)
{
continue;
}
if (uc.ChildConstraint == null || uc.ChildConstraint.Table.Rows.Count == 0)
{
continue;
}
string err = String.Format("Cannot clear table Parent because " +
"ForeignKeyConstraint {0} enforces Child.", uc.ConstraintName);
throw new InvalidConstraintException(err);
}
}
table.DataTableClearing();
List.Clear();
// Remove from indexes
table.ResetIndexes();
table.DataTableCleared();
OnListChanged(this, new ListChangedEventArgs(ListChangedType.Reset, -1, -1));
}