''UniqueConstraint'' ''serializable'

UniqueConstraint serializable

System.Data (system.data.dll) class

The UniqueConstraint is a rule that prevents duplicate values in a column. There are two ways to create a UniqueConstraint : by setting the DataColumn.Unique property to true for one or more columns, or by using the IDataAdapter.FillSchema( ) method when retrieving a row set that includes a primary key column. You could also create a UniqueConstraint object using the new keyword, however, you need to add it to the DataTable.Constraints collection before it takes effect; simply specifying the column and table information isn't enough. As with all constraints, the UniqueConstraint is enforced only when the DataSet.EnforceConstraints is true (the default).

public class UniqueConstraint : Constraint {
// Public Constructors
   public UniqueConstraint( DataColumn column);  
   public UniqueConstraint( DataColumn[ ] columns);  
   public UniqueConstraint(DataColumn[ ] columns, bool isPrimaryKey);
   public UniqueConstraint(DataColumn column, bool isPrimaryKey);
   public UniqueConstraint( string name, DataColumn column);  
   public UniqueConstraint(string name, DataColumn[ ] columns);
   public UniqueConstraint(string name, DataColumn[ ] columns, bool isPrimaryKey);
   public UniqueConstraint(string name, DataColumn column, bool isPrimaryKey);
   public UniqueConstraint(string name, string[ ] columnNames, bool isPrimaryKey);
// Public Instance Properties
   public virtual DataColumn[ ] Columns{get; } 
   public bool IsPrimaryKey{get; } 
   public override DataTable Table{get; }              // overrides Constraint
// Public Instance Methods
   public override bool Equals( object key2);          // overrides object
   public override int GetHashCode(  );                  // overrides object


System.Object figs/U2192.gif Constraint figs/U2192.gif UniqueConstraint

Returned By


    Part I: ADO.NET Tutorial
    Part II: ADO.NET Core Classes
    Part III: API Quick Reference
    Chapter 34. The System.Data Namespace