public override void CreatePrimaryKey() { if (!IsOneToMany) { PrimaryKey pk = new PrimaryKey(); foreach (Column col in Key.ColumnIterator) { pk.AddColumn(col); } bool nullable = false; foreach (Column col in Element.ColumnIterator) { if (col.IsNullable) { nullable = true; } pk.AddColumn(col); } // some databases (Postgres) will tolerate nullable // column in a primary key - others (DB2) won't if (!nullable) { CollectionTable.PrimaryKey = pk; } } else { // Create an index on the key columns? } }
/// <summary></summary> public override void CreatePrimaryKey() { if ( !IsOneToMany ) { PrimaryKey pk = new PrimaryKey(); foreach( Column col in Key.ColumnCollection ) { pk.AddColumn( col ); } bool nullable = false; foreach( Column col in Element.ColumnCollection ) { if( col.IsNullable ) { nullable = true; } pk.AddColumn( col ); } // some databases (Postgres) will tolerate nullable // column in a primary key - others (DB2) won't if( !nullable ) { CollectionTable.PrimaryKey = pk; } } else { // Create an index on the key columns? } }
public override void CreatePrimaryKey() { if (!IsOneToMany) { PrimaryKey pk = new PrimaryKey(); foreach (Column col in Key.ColumnCollection) { pk.AddColumn(col); } // Index should be last column listed foreach (Column col in Index.ColumnCollection) { pk.AddColumn(col); } CollectionTable.PrimaryKey = pk; } }
/// <summary></summary> public override void CreatePrimaryKey() { if (!IsOneToMany) { PrimaryKey pk = new PrimaryKey(); foreach (Column col in Key.ColumnCollection) { pk.AddColumn(col); } // Index should be last column listed foreach (Column col in Index.ColumnCollection) { pk.AddColumn(col); } CollectionTable.PrimaryKey = pk; } }
/// <summary></summary> public override void CreatePrimaryKey() { if ( !IsOneToMany ) { PrimaryKey pk = new PrimaryKey(); foreach( Column col in Identifier.ColumnCollection ) { pk.AddColumn( col ); } CollectionTable.PrimaryKey = pk; } //else // Create an index on the key columns? }
/// <summary> /// Creates the <see cref="PrimaryKey"/> for the <see cref="Table"/> /// this type is persisted in. /// </summary> /// <param name="dialect">The <see cref="Dialect.Dialect"/> that is used to Alias columns.</param> public virtual void CreatePrimaryKey(Dialect.Dialect dialect) { PrimaryKey pk = new PrimaryKey(); pk.Table = table; pk.Name = PKAlias.ToAliasString(table.Name, dialect); table.PrimaryKey = pk; foreach (Column col in Key.ColumnCollection) { pk.AddColumn(col); } }
/// <summary></summary> public override void CreatePrimaryKey() { if (!IsOneToMany) { PrimaryKey pk = new PrimaryKey(); foreach (Column col in Identifier.ColumnCollection) { pk.AddColumn(col); } CollectionTable.PrimaryKey = pk; } //else // Create an index on the key columns? }
/// <summary> /// Creates the <see cref="PrimaryKey"/> for the <see cref="Table"/> /// this type is persisted in. /// </summary> /// <param name="dialect">The <see cref="Dialect.Dialect"/> that is used to Alias columns.</param> public virtual void CreatePrimaryKey(Dialect.Dialect dialect) { PrimaryKey pk = new PrimaryKey(); pk.Table = table; pk.Name = PKAlias.ToAliasString(table.Name, dialect); table.PrimaryKey = pk; foreach (Column col in Key.ColumnCollection) { pk.AddColumn(col); } }