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; }
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; }
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; }
/// <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>(); }
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); }
/// <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; }