/// <summary>Creates new instance of the <see cref="UserClaimsTableSqlCommands"/> class.</summary> /// <param name="tableNomenclature"> /// The <see cref="UserClaimsTableNomenclature"/> to use when interacting with the database. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if the <paramref name="tableNomenclature"/> parameter is <c>null</c>. /// </exception> public UserClaimsTableSqlCommands(UserClaimsTableNomenclature tableNomenclature) { if (tableNomenclature == null) { throw new ArgumentNullException(nameof(tableNomenclature)); } TableNomenclature = tableNomenclature; }
/// <summary>Generates the DDL necessary to create the <see cref="UserClaimsTable"/>.</summary> /// <param name="tableNomenclature">The table nomenclature to use.</param> /// <returns>The SQL script that will create the <see cref="UserClaimsTable"/> in the database.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if the <paramref name="tableNomenclature"/> parameter is <c>null</c> /// </exception> public static string GenerateCreationSql(UserClaimsTableNomenclature tableNomenclature) { if (tableNomenclature == null) { throw new ArgumentNullException(nameof(tableNomenclature)); } var ddlScript = new System.Text.StringBuilder(); ddlScript.AppendLine($"CREATE TABLE \"{tableNomenclature.TableName}\" (") .AppendLine($" \"{tableNomenclature.ClaimIdColumnName}\" NUMBER(10, 0) NOT NULL,") .AppendLine($" \"{tableNomenclature.UserIdColumnName}\" VARCHAR2(128 BYTE) NOT NULL,") .AppendLine($" \"{tableNomenclature.ClaimTypeColumnName}\" CLOB,") .AppendLine($" \"{tableNomenclature.ClaimValueColumnName}\" CLOB,") .AppendLine($" CONSTRAINT \"PK_{tableNomenclature.TableName}\" PRIMARY KEY (\"{tableNomenclature.ClaimIdColumnName}\"),") .AppendLine($" CONSTRAINT \"FK_{tableNomenclature.TableName}_{tableNomenclature.UserIdColumnName}\"") .AppendLine($" FOREIGN KEY (\"{tableNomenclature.UserIdColumnName}\")") .AppendLine($" REFERENCES \"{tableNomenclature.TableName}\" (\"{tableNomenclature.UserIdColumnName}\") ON DELETE CASCADE") .AppendLine(");"); return(ddlScript.ToString()); }
/// <summary> /// Creates a new instance of <see cref="OracleContextNomenclature"/>, /// using the default naming settings for each of the database objects. /// </summary> public OracleContextNomenclature() { RolesTableNomenclature = new RolesTableNomenclature(tableName: "ROLES", roleIdColumnName: "ID", roleNameColumnName: "ROLE_NAME"); UserClaimsTableNomenclature = new UserClaimsTableNomenclature(tableName: "USER_CLAIMS", claimIdColumnName: "ID", userIdColumnName: "USER_ID", claimTypeColumnName: "CLAIM_TYPE", claimValueColumnName: "CLAIM_VALUE"); UserLoginsTableNomenclature = new UserLoginsTableNomenclature(tableName: "USER_LOGINS", userIdColumnName: "USER_ID", providerNameColumnName: "PROVIDER_NAME", providerKeyColumnName: "PROVIDER_KEY"); UserRolesTableNomenclature = new UserRolesTableNomenclature(tableName: "USER_ROLES", userIdColumnName: "USER_ID", roleIdColumnName: "ROLE_ID"); UsersTableNomenclature = new UsersTableNomenclature(tableName: "USERS", userIdColumnName: "ID", userNameColumnName: "USERNAME", emailAddressColumnName: "EMAIL", emailConfirmedColumnName: "EMAIL_CONFIRMED", passwordHashColumnName: "PASSWORD_HASH", securityStampColumnName: "SECURITY_STAMP", phoneNumberColumnName: "PHONE_NUMBER", phoneNumberConfirmedColumnName: "PHONE_NUMBER_CONFIRMED", twoFactorAuthorizationEnabledColumnName: "TWO_FACTOR_AUTH_ENABLED", lockoutEndDateUtcColumnName: "LOCKOUT_END_DATE_UTC", lockoutEnabledColumnName: "LOCKOUT_ENABLED", accessFailedCountColumnName: "ACCESS_FAILED_COUNT"); }