Esempio n. 1
0
 void SetUniqueIndexColumns(Smo.Index idx, DataColumn[] dc)
 {
     idx.IsUnique = true;
     foreach (DataColumn c in dc)
     {
         Smo.IndexedColumn ic = new Smo.IndexedColumn(idx, c.ColumnName);
         idx.IndexedColumns.Add(ic);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Attempts to locate a simple primary key for a table (a key where the
        /// index consists of just one column)
        /// </summary>
        /// <param name="t">The table of interest</param>
        /// <returns>The column that defines the primary key (null if the table does
        /// not have a primary key, or it consists of more than one column)</returns>
        public static Smo.Column GetSimplePrimaryKeyColumn(Smo.Table t)
        {
            Smo.Index x = GetPrimaryKey(t);
            if (x == null || x.IndexedColumns.Count != 1)
            {
                return(null);
            }

            Smo.IndexedColumn xc = x.IndexedColumns[0];
            return(t.Columns[xc.Name]);
        }