Skip to content

Instantly share code, notes, and snippets.

@Talljoe
Created April 26, 2011 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Talljoe/941728 to your computer and use it in GitHub Desktop.
Save Talljoe/941728 to your computer and use it in GitHub Desktop.
Paging bug in Massive.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear />
<add name="TestDb"
connectionString="Data Source=.\sqlexpress;Initial Catalog=MassiveTest;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
USE [master]
GO
/****** Object: Database [MassiveTest] Script Date: 04/25/2011 20:00:59 ******/
CREATE DATABASE [MassiveTest] ON PRIMARY
( NAME = N'MassiveTest', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\MassiveTest.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'MassiveTest_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\MassiveTest_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
USE [MassiveTest]
GO
/****** Object: Table [dbo].[Appliance] Script Date: 04/25/2011 19:58:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Appliance](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](100) NOT NULL,
[Color] [nvarchar](50) NOT NULL,
[Amps] [int] NOT NULL,
CONSTRAINT [PK_Appliance] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT INTO [MassiveTest].[dbo].Appliance VALUES ('Toaster', 'Stainless Steel', 7)
INSERT INTO [MassiveTest].[dbo].Appliance VALUES ('Vacuum', 'Red', 12)
INSERT INTO [MassiveTest].[dbo].Appliance VALUES ('Stove', 'White', 30)
INSERT INTO [MassiveTest].[dbo].Appliance VALUES ('Microwave', 'White', 20)
GO
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B4611364-7863-4961-96D5-8F170DD74809}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PagingBug</RootNamespace>
<AssemblyName>PagingBug</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Massive.cs" />
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
namespace PagingBug
{
using System;
using System.Collections.Generic;
using System.Linq;
using Massive;
internal class Program
{
private static void Main()
{
Console.WriteLine("Should print [1,2] [3,4] []");
var model = new DynamicModel(tableName: "Appliance");
int count;
int page = 1;
do
{
var result = model.Paged(orderBy: "id", pageSize: 2, currentPage: page++);
var items = ((IEnumerable<dynamic>)result.Items).ToList();
count = items.Count();
Console.WriteLine("Page #{0}: [{1}]", page, String.Join(",", items.Select(i => i.Id.ToString())));
} while (count > 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment