Пример #1
0
        public IndexColumn(IModelledSqlExpression expression, IndexColumnOrder order = IndexColumnOrder.Ascending)
        {
            if (!order.IsValid())
            {
                throw new ArgumentException($"The { nameof(IndexColumnOrder) } provided must be a valid enum.", nameof(order));
            }

            Expression = expression ?? throw new ArgumentNullException(nameof(expression));
            Order      = order;
        }
Пример #2
0
            public PrimaryKey(IndexColumnOrder columnOrder = IndexColumnOrder.Ascending, bool autoIncrement = false)
                : base(ColumnConstraintType.PrimaryKey)
            {
                if (!columnOrder.IsValid())
                {
                    throw new ArgumentException($"The { nameof(IndexColumnOrder) } provided must be a valid enum.", nameof(columnOrder));
                }

                ColumnOrder   = columnOrder;
                AutoIncrement = autoIncrement;
            }
Пример #3
0
        public IndexColumn(ExpressionColumn column, IndexColumnOrder order = IndexColumnOrder.Ascending)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (!order.IsValid())
            {
                throw new ArgumentException($"The { nameof(IndexColumnOrder) } provided must be a valid enum.", nameof(order));
            }

            Expression = column.Expression;
            Order      = order;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlDatabaseIndexColumn"/> class.
        /// </summary>
        /// <param name="expression">An expression that represents the index column.</param>
        /// <param name="order">The sorting order applied to the index column.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression"/> is <c>null</c>, empty or whitespace.</exception>
        /// <exception cref="ArgumentException"><paramref name="order"/> is an invalid enum value.</exception>
        public PostgreSqlDatabaseIndexColumn(string expression, IndexColumnOrder order)
        {
            if (expression.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(expression));
            }
            if (!order.IsValid())
            {
                throw new ArgumentException($"The { nameof(IndexColumnOrder) } provided must be a valid enum.", nameof(order));
            }

            Expression       = expression;
            Order            = order;
            DependentColumns = Array.Empty <IDatabaseColumn>();
        }
Пример #5
0
        internal IndexedColumn WithColumnOrder(IndexColumnOrder columnOrder)
        {
            if (!columnOrder.IsValid())
            {
                throw new ArgumentException($"The { nameof(IndexColumnOrder) } provided must be a valid enum.", nameof(columnOrder));
            }

            var newColumn = Name != null
                ? new IndexedColumn(Name)
                : new IndexedColumn(Expression);

            newColumn.Collation   = Collation;
            newColumn.ColumnOrder = ColumnOrder;

            return(newColumn);
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DatabaseIndexColumn"/> class.
        /// </summary>
        /// <param name="expression">A textual expression defining the index column.</param>
        /// <param name="dependentColumns">Columns that the index column is dependent upon.</param>
        /// <param name="order">The index column ordering.</param>
        /// <exception cref="ArgumentNullException"><paramref name="dependentColumns"/> is <c>null</c> or contains <c>null</c> values. Alternatively if <paramref name="expression"/> is <c>null</c>, empty or whitespace.</exception>
        /// <exception cref="ArgumentException"><paramref name="order"/> is an invalid enum.</exception>
        public DatabaseIndexColumn(string expression, IEnumerable <IDatabaseColumn> dependentColumns, IndexColumnOrder order)
        {
            if (expression.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(expression));
            }
            if (dependentColumns == null || dependentColumns.AnyNull())
            {
                throw new ArgumentNullException(nameof(dependentColumns));
            }
            if (!order.IsValid())
            {
                throw new ArgumentException($"The { nameof(IndexColumnOrder) } provided must be a valid enum.", nameof(order));
            }

            Expression       = expression;
            DependentColumns = dependentColumns.ToList();
            Order            = order;
        }