Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 6,124 | Comments: 45,483

filter by tags archive

Query Batch: Concrete Syntax

time to read 3 min | 417 words

Thanks for all the feedback about this feature, I have implemented it and you can find the code here.  Instead of explaining, I am going to let the test speak for themselves. Consider this a first iteration, and I am now accepting patches for this. :-)

 

[Test]
public void CanUseCriteriaBatch()
{
    ICollection<SMS> loadedMSGs = null;
    new CriteriaBatch(session)
        .Add(DetachedCriteria.For<SMS>(), Order.Asc("id"))
        .OnRead<SMS>(delegate(ICollection<SMS> msgs) { loadedMSGs = msgs; })
        .Execute();
    Assert.IsNotNull(loadedMSGs);
}

[Test]
public void CanUseCriteriaBatchForUniqueResult()
{
    ICollection<SMS> loadedMSGs = null;
    SMS loadedMsg = null;
    new CriteriaBatch(session)
        .Add(DetachedCriteria.For<SMS>(), Order.Asc("id"))
            .OnRead<SMS>(delegate(ICollection<SMS> msgs) { loadedMSGs = msgs; })
        .Add(DetachedCriteria.For<SMS>())
            .Paging(0, 1)
            .OnRead<SMS>(delegate(SMS msg) { loadedMsg = msg; })
        .Execute();
    Assert.IsNotNull(loadedMSGs);
    Assert.IsNotNull(loadedMsg);
}

[Test]
public void CanUseCriteriaBatchWithAutomaticCountQuery()
{
    ICollection<SMS> loadedMSGs = null;
    int msg_count = 0;
    SMS loadedMsg = null;
    new CriteriaBatch(session)
     .Add(DetachedCriteria.For<SMS>(), Order.Asc("id"))
         .OnRead<SMS>(delegate(ICollection<SMS> msgs, int count) { loadedMSGs = msgs;
                                                                     msg_count = count;})
     .Add(DetachedCriteria.For<SMS>())
         .Paging(0, 1)
          .OnRead<SMS>(delegate(SMS msg) { loadedMsg = msg; })
    .Execute();
    Assert.IsNotNull(loadedMSGs);
    Assert.AreEqual(1, msg_count);
    Assert.IsNotNull(loadedMsg);

}

Comments

Maor

Great post!

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. RavenDB 3.5 whirl wind tour: I’ll find who is taking my I/O bandwidth and they SHALL pay - 5 hours from now
  2. The design of RavenDB 4.0: Physically segregating collections - about one day from now
  3. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - 2 days from now
  4. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 5 days from now
  5. The design of RavenDB 4.0: Voron has a one track mind - 6 days from now

And 12 more posts are pending...

There are posts all the way to May 30, 2016

RECENT SERIES

  1. RavenDB 3.5 whirl wind tour (14):
    02 May 2016 - You want all the data, you can’t handle all the data
  2. The design of RavenDB 4.0 (13):
    03 May 2016 - Making Lucene reliable
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats