/// <summary>Creates new instance of the <see cref="RolesTableSqlCommands"/> class.</summary> /// <param name="tableNomenclature"> /// The <see cref="TableNomenclature"/> to use when interacting with the database. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if the <paramref name="tableNomenclature"/> parameter is <c>null</c>. /// </exception> public RolesTableSqlCommands(RolesTableNomenclature tableNomenclature) { if (tableNomenclature == null) { throw new ArgumentNullException(nameof(tableNomenclature)); } TableNomenclature = tableNomenclature; }
/// <summary>Creates new instance of the <see cref="UserRolesTableSqlCommands"/> class.</summary> /// <param name="userRolesTableNomenclature"> /// The <see cref="AdoNet.UserRolesTableNomenclature"/> to use when interacting with the database. /// </param> /// <param name="rolesTableNomenclature"> /// The <see cref="AdoNet.RolesTableNomenclature"/> to use when interacting with the database. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if the <paramref name="userRolesTableNomenclature"/> or /// <paramref name="rolesTableNomenclature"/> parameter is <c>null</c>. /// </exception> public UserRolesTableSqlCommands(UserRolesTableNomenclature userRolesTableNomenclature, RolesTableNomenclature rolesTableNomenclature) { if (userRolesTableNomenclature == null) { throw new ArgumentNullException(nameof(userRolesTableNomenclature)); } if (rolesTableNomenclature == null) { throw new ArgumentNullException(nameof(rolesTableNomenclature)); } UserRolesTableNomenclature = userRolesTableNomenclature; RolesTableNomenclature = rolesTableNomenclature; }
/// <summary>Generates the DDL necessary to create the <see cref="RolesTable"/>.</summary> /// <param name="tableNomenclature">The table nomenclature to use.</param> /// <returns>The SQL script that will create the <see cref="RolesTable"/> in the database.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if the <paramref name="tableNomenclature"/> parameter is <c>null</c> /// </exception> public static string GenerateCreationSql(RolesTableNomenclature tableNomenclature) { if (tableNomenclature == null) { throw new ArgumentNullException(nameof(tableNomenclature)); } var ddlScript = new System.Text.StringBuilder(); ddlScript.AppendLine($"CREATE TABLE \"{tableNomenclature.TableName}\"") .AppendLine($" \"{tableNomenclature.RoleIdColumnName}\" VARCHAR2(128 BYTE) NOT NULL,") .AppendLine($" \"{tableNomenclature.RoleNameColumnName}\" VARCHAR2(256 BYTE) NOT NULL,") .AppendLine($" CONSTRAINT \"PK_{tableNomenclature.TableName}\" PRIMARY KEY (\"{tableNomenclature.RoleIdColumnName}\")") .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"); }
/// <summary>Generates the DDL necessary to create the <see cref="UserRolesTable"/>.</summary> /// <param name="userRolesNomenclature">The instance of <see cref="AdoNet.UserRolesTableNomenclature"/> to use.</param> /// <param name="rolesNomenclature">The instance of <see cref="AdoNet.RolesTableNomenclature"/> to use.</param> /// <param name="usersNomenclature">The instance of <see cref="UsersTableNomenclature"/> to use.</param> /// <returns>The SQL script that will create the <see cref="UserRolesTable"/> in the database.</returns> /// <exception cref="ArgumentNullException"> /// Thrown if the <paramref name="userRolesNomenclature"/>, /// <paramref name="rolesNomenclature"/>, or /// <paramref name="usersNomenclature"/> parameter is <c>null</c> /// </exception> public static string GenerateCreationSql(UserRolesTableNomenclature userRolesNomenclature, RolesTableNomenclature rolesNomenclature, UsersTableNomenclature usersNomenclature) { if (userRolesNomenclature == null) { throw new ArgumentNullException(nameof(userRolesNomenclature)); } if (rolesNomenclature == null) { throw new ArgumentNullException(nameof(rolesNomenclature)); } if (usersNomenclature == null) { throw new ArgumentNullException(nameof(usersNomenclature)); } var ddlScript = new System.Text.StringBuilder(); ddlScript.AppendLine($"CREATE TABLE \"{userRolesNomenclature.TableName}\" (") .AppendLine($" \"{userRolesNomenclature.RoleIdColumnName}\" VARCHAR2(128 BYTE) NOT NULL,") .AppendLine($" \"{userRolesNomenclature.UserIdColumnName}\" VARCHAR2(128 BYTE) NOT NULL,") .AppendLine($" CONSTRAINT \"PK_{userRolesNomenclature.TableName}\"") .AppendLine($" PRIMARY KEY (\"{userRolesNomenclature.UserIdColumnName}\", \"{userRolesNomenclature.RoleIdColumnName}\") USING INDEX (") .AppendLine($" CREATE UNIQUE INDEX \"PK_{userRolesNomenclature.TableName}_ID\" ON \"{userRolesNomenclature.TableName}\" (") .AppendLine($" \"{userRolesNomenclature.UserIdColumnName}\",") .AppendLine($" \"{userRolesNomenclature.RoleIdColumnName}\"") .AppendLine($" )") .AppendLine($" ),") .AppendLine($" CONSTRAINT \"FK_{userRolesNomenclature.TableName}_{userRolesNomenclature.RoleIdColumnName}\"") .AppendLine($" FOREIGN KEY (\"{userRolesNomenclature.RoleIdColumnName}\")") .AppendLine($" REFERENCES \"{rolesNomenclature.TableName}\" (\"{rolesNomenclature.RoleIdColumnName}\") ON DELETE CASCADE,") .AppendLine($" CONSTRAINT \"FK_{userRolesNomenclature.TableName}_{userRolesNomenclature.UserIdColumnName}\"") .AppendLine($" FOREIGN KEY (\"{userRolesNomenclature.UserIdColumnName}\")") .AppendLine($" REFERENCES \"{usersNomenclature.TableName}\" (\"{usersNomenclature.UserIdColumnName}\") ON DELETE CASCADE") .AppendLine($")"); return(ddlScript.ToString()); }