Exemplo n.º 1
0
        ///<summary>Initialize a new Table with a specified name, indices,
        /// check constraints, and columns.</summary>
        ///<param name="name">The name of the table.</param>
        ///<param name="indices">The index constraints of the table.</param>
        ///<param name="checks">The check constraints of the table.</param>
        ///<param name="columns">The columns of the table.</param>
        public AbsTable(string name, IConstraint[] indices, IConstraint[] checks,
                        params IColumn[] columns)
        {
            this.name    = name;
            this.columns = columns is null ? new IColumn[0] : (IColumn[])columns.Clone();
            this.indices = indices is null ? new IConstraint[0] : (IConstraint[])indices.Clone();
            this.checks  = checks is null ? new IConstraint[0] : (IConstraint[])checks.Clone();

            /*List<IColumn> keys = new List<IColumn>(columns.Length);
             * foreach (IColumn col in columns)
             *      if (col.HasConstraint(ConstraintType.PRIMARY_KEY)) keys.Add(col);
             * pk = new PrimaryKeyConstraint(keys.ToArray());*/

            pk = new PrimaryKeyConstraint(Utilities.ConvertIf(columns, (col) =>
                                                              (col.HasConstraint(ConstraintType.PRIMARY_KEY), col)));
        }
Exemplo n.º 2
0
 public virtual bool Equals(IPkConstraint other)
 {
     if (Object.ReferenceEquals(this, other))
     {
         return(true);
     }
     if (other is null || other.KeyColumns.Length != KeyColumns.Length)
     {
         return(false);
     }
     for (int i = 0; i < KeyColumns.Length; i++)
     {
         if (!other.KeyColumns[i].Equals(KeyColumns[i]))
         {
             return(false);
         }
     }
     return(true);
 }