Unless you specify order, the DB is free to choose whatever order it likes.Let
us take this:
select top 10 * from Foo
The DB is free to return completely different result sets for this query if
you execute it twice
On Wed, Oct 22, 2008 at 3:16 AM, Jason Meckley <[EMAIL PROTECTED]>wrote:
>
> I don't follow. What do you mean "orders may be indeterministic"?
>
> On Oct 21, 5:02 pm, "Tuna Toksöz" <[EMAIL PROTECTED]> wrote:
> > The orders may be indeterministic
> >
> > On Tue, Oct 21, 2008 at 11:58 PM, Jason Meckley <[EMAIL PROTECTED]
> >wrote:
> >
> >
> >
> >
> >
> > > I'm having a difficult time understanding page, specifically
> > > SetFirstResult() and SetMaxResults()
> >
> > > from what I read on different posts SetFirstResult is the zero-based
> > > index of the record you want to start with. SetMaxResults is the
> > > number of records you want to return.
> >
> > > if this is correct then why do tests:
> > > Should_get_foos_21_through_30
> > > Should_get_foos_31_through_40
> > > fail?
> >
> > > //Foo has 1 property Id which is readonly. The id is assigned via
> > > ctor.
> >
> > > namespace Paging.Spike.Core.Test
> > > {
> > > [TestFixture]
> > > public class PagingWithNhibernateSpec
> > > {
> > > private ISessionFactory factory;
> > > private Configuration cfg;
> > > private ISession session;
> > > private const int PAGE_SIZE = 10;
> >
> > > [TestFixtureSetUp]
> > > public void TestFixtureSetup()
> > > {
> > > cfg = new Configuration().Configure();
> > > factory = cfg.BuildSessionFactory();
> > > }
> >
> > > [TestFixtureTearDown]
> > > public void TestFixtureTeardown()
> > > {
> > > factory.Dispose();
> > > }
> >
> > > [SetUp]
> > > public void SetUp()
> > > {
> > > session = factory.OpenSession();
> > > new SchemaExport(cfg).Execute(false, true, false, true,
> > > session.Connection, null);
> > > using(ITransaction transaction =
> > > session.BeginTransaction())
> > > {
> > > for (int i = 1; i <= 100; i++)
> > > session.Save(new Foo(i));
> > > transaction.Commit();
> > > }
> > > }
> >
> > > [TearDown]
> > > public void TearDown()
> > > {
> > > session.Dispose();
> > > }
> >
> > > [Test]
> > > public void Should_get_foos_01_through_10()
> > > {
> > > ValidateIdsStartingWithId(1,
> > > GetResultsStartingAtIndex(0));
> > > }
> >
> > > [Test]
> > > public void Should_get_foos_11_through_20()
> > > {
> > > ValidateIdsStartingWithId(11,
> > > GetResultsStartingAtIndex(10));
> > > }
> >
> > > [Test]
> > > public void Should_get_foos_21_through_30()
> > > {
> > > ValidateIdsStartingWithId(21,
> > > GetResultsStartingAtIndex(20));
> > > }
> >
> > > [Test]
> > > public void Should_get_foos_31_through_40()
> > > {
> > > ValidateIdsStartingWithId(31,
> > > GetResultsStartingAtIndex(30));
> > > }
> >
> > > private IList<Foo> GetResultsStartingAtIndex(int firstResult)
> > > {
> > > return session
> > > .CreateCriteria(typeof (Foo))
> > > .SetFirstResult(firstResult)
> > > .SetMaxResults(PAGE_SIZE)
> > > .List<Foo>();
> > > }
> >
> > > private static void ValidateIdsStartingWithId(int id,
> > > ICollection<Foo> foos)
> > > {
> > > foreach (Foo foo in foos)
> > > Console.WriteLine(foo);
> >
> > > Assert.AreEqual(PAGE_SIZE, foos.Count);
> >
> > > foreach (Foo foo in foos)
> > > Assert.AreEqual(id++, foo.Id);
> > > }
> > > }
> > > }
> >
> > --
> > Tuna Toksöz
> >
> > Typos included to enhance the readers attention!
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---