Home All Groups Group Topic Archive Search About

useless UniqueConstraint constructors...

Author
19 Apr 2006 1:23 PM
Dan
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

Author
26 Apr 2006 9:43 PM
Mark Ashton
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.


Show quote
"Dan" wrote:

> 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

AddThis Social Bookmark Button