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: 5,972 | Comments: 44,523

filter by tags archive

Query Batch: Concrete Syntax


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

No future posts left, oh my!

RECENT SERIES

  1. Production postmortem (5):
    29 Jul 2015 - The evil licensing code
  2. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
  3. API Design (7):
    20 Jul 2015 - We’ll let the users sort it out
  4. What is new in RavenDB 3.5 (3):
    15 Jul 2015 - Exploring data in the dark
  5. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats