internal static void SetAsPrimaryKey(ConstraintCollection collection, UniqueConstraint newPrimaryKey)
{
//not null
if (null == collection)
{
throw new ArgumentNullException("ConstraintCollection can't be null.");
}
//make sure newPrimaryKey belongs to the collection parm unless it is null
if (collection.IndexOf(newPrimaryKey) < 0 && (null != newPrimaryKey))
{
throw new ArgumentException("newPrimaryKey must belong to collection.");
}
//Get existing pk
UniqueConstraint uc = GetPrimaryKeyConstraint(collection);
//clear existing
if (null != uc)
{
uc._isPrimaryKey = false;
}
//set new key
if (null != newPrimaryKey)
{
newPrimaryKey._isPrimaryKey = true;
}
}