예제 #1
0
        public static CreateTable ForeignKey(this CreateTable @this,
                                             IEnumerable <string> columnNames,
                                             string references,
                                             IEnumerable <string> referencesColumnNames = null,
                                             ForeignKeyTriggers onDelete = default(ForeignKeyTriggers),
                                             ForeignKeyTriggers onUpdate = default(ForeignKeyTriggers),
                                             Deferrable deferrable       = default(Deferrable)
                                             )
        {
            if (referencesColumnNames == null)
            {
                referencesColumnNames = columnNames;
            }

            @this.TableConstraints.Add(new ForeignKeyConstraint()
            {
                ColumnNames          = columnNames,
                ReferenceColumnNames = referencesColumnNames,
                OnDelete             = onDelete,
                OnUpdate             = onUpdate,
                Deferrable           = deferrable,
            });

            return(@this);
        }
예제 #2
0
 public static CreateTable PrimaryKey(this CreateTable @this, string columnName)
 {
     @this.TableConstraints.Add(new PrimaryKeyConstraint()
     {
         ColumnNames = new string[] { columnName }
     });
     return(@this);
 }
예제 #3
0
 public static CreateTable WithColumns(this CreateTable @this, IEnumerable <ColumnInfo> columns)
 {
     foreach (var c in columns)
     {
         @this.Columns.Add(c);
     }
     return(@this);
 }
예제 #4
0
        public static CreateTable WithTableConstraints(this CreateTable @this, IEnumerable <TableConstraint> tableConstraints)
        {
            foreach (var tc in tableConstraints)
            {
                @this.TableConstraints.Add(tc);
            }

            return(@this);
        }
예제 #5
0
        public static CreateTable WithTableConstraints(this CreateTable @this, IEnumerable <string> tableConstraints)
        {
            foreach (var tc in tableConstraints)
            {
                @this.TableConstraints.Add(new GenericConstraint(tc));
            }

            return(@this);
        }
예제 #6
0
        public static CreateTable Check(this CreateTable @this, string expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            @this.TableConstraints.Add(new CheckConstraint(expression));
            return(@this);
        }
예제 #7
0
        public static CreateTable Unique(this CreateTable @this, string columnName, string onConflict = null)
        {
            if (columnName == null)
            {
                throw new ArgumentNullException("columnName");
            }
            @this.TableConstraints.Add(new UniqueConstraint()
            {
                ColumnNames = new string[] { columnName }, ConflictOption = onConflict
            });

            return(@this);
        }