21 namespace Deveel.Data.Sql.Tables {
24 : this(null, constraintType, tableName, columnNames) {
28 if (tableName == null)
29 throw new ArgumentNullException(
"tableName");
30 if (columnNames == null)
31 throw new ArgumentNullException(
"columnNames");
33 if (columnNames.Length == 0)
34 throw new ArgumentException(
"The provided column names for the constraint is empty.",
"columnNames");
36 ConstraintName = constraintName;
37 ColumnNames = columnNames;
38 TableName = tableName;
46 public string ConstraintName {
get; set; }
48 public string[] ColumnNames {
get;
private set; }
54 public string[] ForeignColumnNames {
get; set; }
63 return Unique(null, tableName, columnNames);
71 return Check(null, tableName, expression, columnNames);
76 CheckExpression = expression
81 return PrimaryKey(null, tableName, columnNames);
89 return ForeignKey(tableName,
new[] {columnName}, refTable,
new[] {refColumn});
93 return ForeignKey(null, tableName, columnNames, refTable, refColumns);
98 if (tableName == null)
99 throw new ArgumentNullException(
"tableName");
100 if (refTable == null)
101 throw new ArgumentNullException(
"refTable");
102 if (columnNames == null || columnNames.Length == 0)
103 throw new ArgumentException(
"At least one column is required",
"columnNames");
104 if (refColumns == null || refColumns.Length == 0)
105 throw new ArgumentException(
"At least one referenced column is required.",
"refColumns");
107 if (columnNames.Length != refColumns.Length)
108 throw new ArgumentException(
"The number of columns in the constraint must match the number of columns referenced.");
111 constraint.ForeignTable = refTable;
112 constraint.ForeignColumnNames = refColumns;
static ConstraintInfo PrimaryKey(ObjectName tableName, params string[] columnNames)
static ConstraintInfo Unique(string constraintName, ObjectName tableName, string[] columnNames)
ConstraintInfo(ConstraintType constraintType, ObjectName tableName, string[] columnNames)
static ConstraintInfo Check(ObjectName tableName, SqlExpression expression, params string[] columnNames)
Describes the name of an object within a database.
ConstraintDeferrability
The type of deferrance of a constraint.
static ConstraintInfo ForeignKey(ObjectName tableName, string[] columnNames, ObjectName refTable, string[] refColumns)
ConstraintInfo(string constraintName, ConstraintType constraintType, ObjectName tableName, string[] columnNames)
ForeignKeyAction
Enumerates the foreign key referential trigger actions.
static ConstraintInfo Check(string constraintName, ObjectName tableName, SqlExpression expression, params string[] columnNames)
ConstraintType
An enumeration of all the supported kinds of constraints within a table or a schema.
static ConstraintInfo ForeignKey(string constraintName, ObjectName tableName, string[] columnNames, ObjectName refTable, string[] refColumns)
static ConstraintInfo PrimaryKey(string constraintName, ObjectName tableName, params string[] columnNames)
static ConstraintInfo ForeignKey(ObjectName tableName, string columnName, ObjectName refTable, string refColumn)
Defines the base class for instances that represent SQL expression tree nodes.
static ConstraintInfo Unique(ObjectName tableName, params string[] columnNames)