/// <summary> /// Initializes a new instance of the <see cref="Constraint" /> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="column">The column.</param> public Constraint(string name, ContraintType type, string column) { Name = name; Type = type; Columns = new List<string> {column}; }
/// <summary> /// Initializes a new instance of the <see cref="Constraint"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="columns">The columns.</param> public Constraint(string name, ContraintType type, List<string> columns) { Name = name; Type = type; Columns = columns; }
/// <summary> /// Converts a constraint to a string /// </summary> /// <param name="type">The type.</param> /// <returns></returns> private string ConvertToString(ContraintType type) { switch(type) { case ContraintType.PrimaryKey: return "PRIMARY KEY"; case ContraintType.Constraint: if (Unique) { return "Unique"; } throw new DotNetWorkQueueException("Only unique constraints are supported; set the unique flag to true. For primary keys, use the primary key type instead. For indexes, specify an index type instead."); default: return type.ToString().ToUpperInvariant(); } }