public static void AddConstraint(this IQueryContext context, ObjectName tableName, ConstraintInfo constraintInfo) { if (constraintInfo.ConstraintType == ConstraintType.PrimaryKey) { var columnNames = constraintInfo.ColumnNames; if (columnNames.Length > 1) { throw new ArgumentException(); } context.AddPrimaryKey(tableName, columnNames[0], constraintInfo.ConstraintName); } else if (constraintInfo.ConstraintType == ConstraintType.Unique) { context.AddUniqueKey(tableName, constraintInfo.ColumnNames, constraintInfo.ConstraintName); } else if (constraintInfo.ConstraintType == ConstraintType.Check) { context.AddCheck(tableName, constraintInfo.CheckExpression, constraintInfo.ConstraintName); } else if (constraintInfo.ConstraintType == ConstraintType.ForeignKey) { context.AddForeignKey(tableName, constraintInfo.ColumnNames, constraintInfo.ForeignTable, constraintInfo.ForeignColumnNames, constraintInfo.OnDelete, constraintInfo.OnUpdate, constraintInfo.ConstraintName); } }