Example #1
0
        /// <summary>
        /// Creates an instance of <c>TableSchema</c> with specified <paramref name="name"/>,
        /// which belongs to <paramref name="database"/>.
        /// </summary>
        /// <param name="database">Database into which table belongs to. Value can be <see langword="null"/>.</param>
        /// <param name="name">Table's name.</param>
        /// <exception cref="ArgumentNullException">Value of <paramref name="name"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">Value of <paramref name="name"/> is empty string, or string containing only
        /// whitespace characters.</exception>
        public TableSchema(DatabaseSchema database, string name)
        {
            Name = Check.NotNullOrWhiteSpace(name, nameof(name));

            Database    = database;
            Columns     = new ColumnSchemaCollection(this);
            Indexes     = new IndexSchemaCollection(this);
            ForeignKeys = new ForeignKeySchemaCollection(this);
        }
Example #2
0
        /// <summary>
        /// Vytvorí schému tabuľky <paramref name="name"/> pre databázu <paramref name="database"/>.
        /// </summary>
        /// <param name="database">Databáza, v ktorej je tabuľka. Hodnota nie je povinná, môže byť <c>null</c>.</param>
        /// <param name="name">Meno tabuľky. Je povinné.</param>
        /// <exception cref="ArgumentNullException">Hodnota <paramref name="name"/> je <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Hodnota <paramref name="name"/> je prázdny reťazec, alebo reťazec bielych znakov.
        /// </exception>
        public TableSchema(DatabaseSchema database, string name)
        {
            Check.NotNullOrWhiteSpace(name, nameof(name));

            Database    = database;
            Name        = name;
            Columns     = new ColumnSchemaCollection(this);
            PrimaryKey  = new IndexSchema($"PK_{name}", IndexType.PrimaryKey, true);
            Indexes     = new IndexSchemaCollection(this);
            ForeignKeys = new ForeignKeySchemaCollection(this);
        }