ForeignKeyConstraint serializable

ForeignKeyConstraint serializable

System.Data ( class

The ForeignKeyConstraint represents a restriction on a set of related columns . Usually, you don't create a ForeignKeyConstraint directly. Instead, you define and add a DataRelation to the DataSet.Relations collection. A corresponding ForeignKeyConstraint is added automatically to the DataTable.Constraints collection of the child table. When you have a ForeignKeyConstraint on a DataTable , certain actions are not allowed (such as creating a parent that references a nonexistent parent row). You can disable checking for constraint violations by setting DataSet.EnforceConstraints to false .

The ForeignKeyConstraint allows you to configure what happens when the parent column is updated ( UpdateRule ), or when the parent row is deleted ( DeleteRule ) or has AcceptChanges( ) called on it ( AcceptRejectRule ). Out of these three options, the DeleteRule is the most commonly used. If you set the DeleteRule to Rule.Cascade , all child rows are deleted when the parent row is deleted. If you use Rule.SetNull , however, the foreign key field in the child record is set to a null value. If you use Rule.SetDefault , the foreign key field is set to a default value when the parent record is deleted. Finally, if you use Rule.None (the default), no action is taken. This results in an error when you attempt to remove a parent with child rows, when you have the DataSet.EnforceConstraints property set to true .

 public class  ForeignKeyConstraint  : Constraint {  // Public Constructors  public  ForeignKeyConstraint  (DataColumn[ ]   parentColumns   , DataColumn[ ]   childColumns   );    public  ForeignKeyConstraint  (DataColumn   parentColumn   , DataColumn   childColumn   );      public  ForeignKeyConstraint  (string   constraintName   , DataColumn[ ]   parentColumns   , DataColumn[ ]   childColumns   );    public  ForeignKeyConstraint  (string   constraintName   , DataColumn   parentColumn   , DataColumn   childColumn   );    public  ForeignKeyConstraint  (string   constraintName   , string   parentTableName   , string[ ]   parentColumnNames   ,          string[ ]   childColumnNames   , AcceptRejectRule   acceptRejectRule   , Rule   deleteRule   , Rule   updateRule   );  // Public Instance Properties  public virtual AcceptRejectRule  AcceptRejectRule  {set; get; }     public virtual DataColumn[ ]  Columns  {get; }     public virtual Rule  DeleteRule  {set; get; }     public virtual DataColumn[ ]  RelatedColumns  {get; }     public virtual DataTable  RelatedTable  {get; }     public override DataTable  Table  {get; }  // overrides Constraint  public virtual Rule  UpdateRule  {set; get; }  // Public Instance Methods  public override bool  Equals  ( object   key   );  // overrides object  public override int  GetHashCode  (  );  // overrides object  } 


System.Object figs/u2192.gif Constraint figs/u2192.gif ForeignKeyConstraint

Returned By


ADO. NET in a Nutshell
ADO.NET in a Nutshell
ISBN: 0596003617
EAN: 2147483647
Year: 2005
Pages: 415

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: