public void Relation_WithMoreThan2100Objects()
        {
            SetDatabaseModifyable();

            var insertedIDs      = Enumerable.Range(0, 4000).Select(x => Guid.NewGuid()).ToArray();
            var insertStatements = insertedIDs.Select(
                id => string.Format(
                    "insert into [OrderItem] (ID, ClassID, OrderID, [Position], [Product]) values ('{0}', 'OrderItem', '{1}', 1, 'Test2100')",
                    id,
                    DomainObjectIDs.Order1.Value));

            var script = string.Join(Environment.NewLine, insertStatements);

            DatabaseAgent.ExecuteCommand(script);

            var order      = DomainObjectIDs.Order1.GetObject <Order> ();
            var orderItems = order.OrderItems;

            Assert.That(orderItems.Count, Is.EqualTo(4002));

            var loadedIDs   = orderItems.Select(oi => (Guid)oi.ID.Value);
            var expectedIDs = insertedIDs.Concat(new[] { (Guid)DomainObjectIDs.OrderItem1.Value, (Guid)DomainObjectIDs.OrderItem2.Value });

            Assert.That(loadedIDs.SetEquals(expectedIDs), Is.True);
        }
        public void Relation_WithMoreThan2100Objects_WithTableInheritance()
        {
            SetDatabaseModifyable();

            var domainObjectIDs = new TableInheritanceDomainObjectIDs(Configuration);

            var insertedIDs      = Enumerable.Range(0, 4000).Select(x => Guid.NewGuid()).ToArray();
            var insertStatements = insertedIDs.Select(
                id => string.Format(
                    "insert into [TableInheritance_File] (ID, ClassID, [Name], [ParentFolderID], [ParentFolderIDClassID], [Size], [FileCreatedAt]) "
                    + "values ('{0}', 'TI_File', 'Test', '{1}', 'TI_Folder', 42, '2006/02/03')",
                    id,
                    domainObjectIDs.Folder1.Value));

            var script = string.Join(Environment.NewLine, insertStatements);

            DatabaseAgent.ExecuteCommand(script);

            var folder          = domainObjectIDs.Folder1.GetObject <TIFolder> ();
            var fileSystemItems = folder.FileSystemItems;

            Assert.That(fileSystemItems.Count, Is.EqualTo(4001));
            var loadedIDs   = fileSystemItems.Select(oi => (Guid)oi.ID.Value);
            var expectedIDs = insertedIDs.Concat(new[] { (Guid)domainObjectIDs.File1.Value });

            Assert.That(loadedIDs.SetEquals(expectedIDs), Is.True);
        }
        private void DisableConstraints(TableDefinition tableDefinition)
        {
            var commandText = string.Format("ALTER TABLE [{0}] NOCHECK CONSTRAINT all", tableDefinition.TableName.EntityName);

            DatabaseAgent.ExecuteCommand(commandText);
        }