public void Creation()
        {
            var TempCheckConstraints = new CheckConstraints();

            Assert.NotNull(TempCheckConstraints);
            Assert.Equal(31, TempCheckConstraints.Order);
        }
        public void GetCommand()
        {
            var TempCheckConstraints = new CheckConstraints();
            var SQLCommand           = TempCheckConstraints.GetCommand();

            Assert.Equal(@"SELECT sys.tables.name as [Table],sys.check_constraints.name as [Name],OBJECT_DEFINITION(sys.check_constraints.object_id) as [Definition]
FROM sys.check_constraints
INNER JOIN sys.tables ON sys.tables.object_id=sys.check_constraints.parent_object_id", SQLCommand);
        }
Esempio n. 3
0
        public override IEnumerable <string> CreateStatements()
        {
            List <string> members = new List <string>();

            members.AddRange(Columns.Select(col => col.GetDefinition()));
            members.AddRange(CheckConstraints.Select(chk => chk.GetDefinition()));
            members.AddRange((Indexes ?? Enumerable.Empty <Index>()).Select(ndx => ndx.GetDefinition()));

            string createMembers = string.Join(",\r\n", members.Select(member => "\t" + member));

            yield return($"CREATE TABLE <{Name}> (\r\n{createMembers}\r\n)");
        }
Esempio n. 4
0
        public String DropSubObjects()
        {
            StringBuilder script = new StringBuilder();

            script.Append(Indexes.DropAllScript());
            script.Append(UniqueConstraints.DropAllScript());
            if (PrimarKey != null)
            {
                script.AppendLine(PrimarKey.DropScript());
            }
            script.Append(CheckConstraints.DropAllScript());
            script.Append(DefaultConstraints.DropAllScript());
            return(script.ToString());
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (InputMappings != null ? InputMappings.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Database != null ? Database.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TableName != null ? TableName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Result != null ? Result.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CheckConstraints.GetHashCode();
         hashCode = (hashCode * 397) ^ FireTriggers.GetHashCode();
         hashCode = (hashCode * 397) ^ UseInternalTransaction.GetHashCode();
         hashCode = (hashCode * 397) ^ KeepIdentity.GetHashCode();
         hashCode = (hashCode * 397) ^ KeepTableLock.GetHashCode();
         hashCode = (hashCode * 397) ^ (Timeout != null ? Timeout.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (BatchSize != null ? BatchSize.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IgnoreBlankRows.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 6
0
        public String CreateSubObjects(Boolean withFk)
        {
            StringBuilder script = new StringBuilder();

            if (PrimarKey != null)
            {
                script.AppendLine(PrimarKey.CreateScript());
                script.AppendLine();
            }

            script.Append(UniqueConstraints.CreateAllScript());
            script.Append(Indexes.CreateAllScript());
            script.Append(CheckConstraints.CreateAllScript());
            script.Append(DefaultConstraints.CreateAllScript());

            if (withFk)
            {
                script.Append(ForeignKeys.CreateAllScript());
            }
            return(script.ToString());
        }
        public void FillSource()
        {
            var TempCheckConstraints = new CheckConstraints();
            var TempSource           = new Source("My Source");
            var TableA           = TempSource.AddTable("Table A", "dbo");
            var ConstraintsToAdd = new List <dynamic>
            {
                new Dynamo(new
                {
                    Table      = "Table A",
                    Name       = "Constraint A",
                    Definition = "(Definition A)"
                })
            };

            TempCheckConstraints.FillSource(ConstraintsToAdd, TempSource);
            var Constraint = TempSource.Tables[0].Constraints[0];

            Assert.Equal("Definition A", Constraint.Definition);
            Assert.Equal("Constraint A", Constraint.Name);
            Assert.Equal(TableA, Constraint.ParentTable);
        }