useless UniqueConstraint constructors...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Why there are UniqueConstraint constructors that accept a bool that sets the
constraint as primary key if the flag is not used??

this is the code inside IsPrimaryKey property...

public bool IsPrimaryKey
{
get
{
if (this.Table == null)
{
return false;
}
return (this == this.Table.primaryKey);
}
}

many thanks,
Dan
 
The UniqueConstraint ctor tracks that boolean so during
table.Constraints.Add, if true and the table doesn't have a primary key - the
constraint will become the primary key.

The IsPrimaryKey property simply returns if this UniqueConstraint instance
is the one used by the DataTable for its primary key.
 
Back
Top