コード例 #1
0
        /// <summary>Generates the DDL necessary to create the <see cref="UserRolesTable"/>.</summary>
        /// <param name="tableNomenclature">The table nomenclature 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="tableNomenclature"/> parameter is <c>null</c>
        /// </exception>
        public static string GenerateCreationSql(UsersTableNomenclature tableNomenclature)
        {
            if (tableNomenclature == null)
            {
                throw new ArgumentNullException(nameof(tableNomenclature));
            }

            var ddlScript = new System.Text.StringBuilder();

            ddlScript.AppendLine($"CREATE TABLE \"{tableNomenclature.TableName}\" (")
            .AppendLine($"  \"{tableNomenclature.UserIdColumnName}\" VARCHAR2(128 BYTE) NOT NULL,")
            .AppendLine($"  \"{tableNomenclature.UserNameColumnName}\" VARCHAR2(256 BYTE) NOT NULL")
            .AppendLine($"  \"{tableNomenclature.EmailAddressColumnName}\" VARCHAR2(256 BYTE) DEFAULT NULL,")
            .AppendLine($"  \"{tableNomenclature.EmailConfirmedColumnName}\" NUMBER(3, 0) NOT NULL,")
            .AppendLine($"  \"{tableNomenclature.PasswordHashColumnName}\" CLOB,")
            .AppendLine($"  \"{tableNomenclature.SecurityStampColumnName}\" CLOB,")
            .AppendLine($"  \"{tableNomenclature.PhoneNumberColumnName}\" VARCHAR2(48 BYTE),")
            .AppendLine($"  \"{tableNomenclature.PhoneNumberConfirmedColumnName}\" NUMBER(3, 0) NOT NULL,")
            .AppendLine($"  \"{tableNomenclature.TwoFactorAuthorizationEnabledColumnName}\" NUMBER(3, 0) NOT NULL,")
            .AppendLine($"  \"{tableNomenclature.LockoutEndDateUtcColumnName}\" DATE DEFAULT NULL,")
            .AppendLine($"  \"{tableNomenclature.LockoutEnabledColumnName}\" NUMBER(3, 0) NOT NULL,")
            .AppendLine($"  \"{tableNomenclature.AccessFailedCountColumnName}\" NUMBER(10, 0) NOT NULL,")
            .AppendLine($"  CONSTRAINT \"PK_{tableNomenclature.TableName}\" PRIMARY KEY (\"{tableNomenclature.UserIdColumnName}\")")
            .AppendLine($");");

            return(ddlScript.ToString());
        }
コード例 #2
0
        /// <summary>Creates new instance of the <see cref="RolesTableSqlCommands"/> class.</summary>
        /// <param name="tableNomenclature">
        ///     The <see cref="UsersTableNomenclature"/> to use when interacting with the database.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if the <paramref name="tableNomenclature"/> parameter is <c>null</c>.
        /// </exception>
        public UsersTableSqlCommands(UsersTableNomenclature tableNomenclature)
        {
            if (tableNomenclature == null)
            {
                throw new ArgumentNullException(nameof(tableNomenclature));
            }

            TableNomenclature = tableNomenclature;
        }
コード例 #3
0
 /// <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");
 }
コード例 #4
0
        /// <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());
        }