public virtual void CreateKey(IActivationLog log) { if (this.Key != null) //protect against multiple processing { return; } // we initially assign temp names this.Key = new EntityKeyInfo(HostEntity, KeyType, HostMember, this.Alias); // add members if (HostMember != null) { Key.KeyMembers.Add(new EntityKeyMemberInfo(HostMember, false)); } else { // it will add errors if it fails HostEntity.TryParseKeySpec(this.MemberNames, log, out Key.KeyMembers, ordered: true); } // construct name Key.ExplicitDbKeyName = this.DbKeyName; // PK if (KeyType.IsSet(KeyType.PrimaryKey)) { if (HostEntity.PrimaryKey == null) { HostEntity.PrimaryKey = Key; Key.KeyMembers.Each(km => km.Member.Flags |= EntityMemberFlags.PrimaryKey); } else { log.Error("Entity {0} has more than one Primary Key specified.", GetHostRef()); } } }
private string GetKeyAttributeName(KeyType keyType) { if (keyType.IsSet(KeyType.PrimaryKey)) { return("PrimaryKey"); } if (keyType.IsSet(KeyType.Clustered)) { return(keyType.IsSet(KeyType.Unique) ? "UniqueClusteredIndex" : "ClusteredIndex"); } if (keyType.IsSet(KeyType.Unique)) { return("Unique"); } if (keyType.IsSet(KeyType.Index)) { return("Index"); } Util.Throw("Invalid key type for attribute: " + keyType); return(null); }
public static string GetKeyNamePrefix(KeyType keyType) { if (keyType.IsSet(KeyType.PrimaryKey)) { return("PK_"); } if (keyType.IsSet(KeyType.ForeignKey)) { return("FK_"); } var prefix = "IX"; if (keyType.IsSet(KeyType.Clustered)) { prefix += "C"; } else if (keyType.IsSet(KeyType.Unique)) { prefix += "U"; } prefix += "_"; return(prefix); }
private string GetKeyAttributeName(KeyType keyType) { if (keyType.IsSet(KeyType.PrimaryKey)) return "PrimaryKey"; if (keyType.IsSet(KeyType.Clustered)) return keyType.IsSet(KeyType.Unique) ? "UniqueClusteredIndex" : "ClusteredIndex"; if (keyType.IsSet(KeyType.Unique)) return "Unique"; if (keyType.IsSet(KeyType.Index)) return "Index"; Util.Throw("Invalid key type for attribute: " + keyType); return null; }