private void Init(string name) { Name = name; Options = new DbEngineOptions(); Columns = new ColumnsCollection(); Constraints = new ConstraintsCollection(this); Indexes = new IndexCollection(this); ModifiedColumns = new ModifiedColumnsCollection(name); }
protected void WriteConstraints(ConstraintsCollection constraints, bool isAdding = false) { var uniq = GetUniqueKeyWriter(); if (ColonBeforeConstraints) { Builder.AppendLine(","); } if (constraints.PrimaryKey != null && !constraints.PrimaryKey.Ignore) { uniq.Write(constraints.PrimaryKey); Builder.AppendLine(","); if (isAdding) Builder.AppendFormat(" {0} ", GetAddConstraintPrefix()); } if (constraints.Uniques.Count > 0) { foreach (var uc in constraints.Uniques) { uniq.Write(uc); Builder.AppendLine(","); if (isAdding) Builder.AppendFormat(" {0} ", GetAddConstraintPrefix()); } } if (constraints.ForeignKeys.Count > 0) { var w = GetForeignKeyWriter(); foreach (var key in constraints.ForeignKeys) { w.Write(key); Builder.AppendLine(","); if (isAdding) Builder.AppendFormat(" {0} ", GetAddConstraintPrefix()); } } if (constraints.Checks.Count > 0) { var chkWriter = GetCheckWriter(); foreach (var ch in constraints.Checks) { chkWriter.Write(ch); Builder.AppendLine(","); if (isAdding) Builder.AppendFormat(" {0} ", GetAddConstraintPrefix()); } } if (isAdding) Builder.RemoveLastIfEquals(" " + GetAddConstraintPrefix() + " "); var custom = constraints.GetSpecificConstraints(_engine); if (!custom.IsNullOrEmpty()) { foreach (var ch in custom) { Builder.AppendLine().Append(ch).AppendLine(","); } } Builder.RemoveLastIfEquals("," + Environment.NewLine); }
public TableSchema(string name) { Name = name; Options= new DbEngineOptions(); Columns= new ColumnsCollection(); Constraints = new ConstraintsCollection(this); Indexes= new IndexCollection(this); ModifiedColumns=new ModifiedColumnsCollection(name); }
public ConstraintsCreator(ConstraintsCollection schema) { _schema = schema; }
public ConstraintsEditor(ConstraintsCollection schema, IModifyTable parent) : base(schema) { _parent = parent; }