Ayende @ Rahien

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


+972 52-548-6969

, @ Q c

Posts: 6,026 | Comments: 44,842

filter by tags archive

And sometimes Things Just Works

time to read 2 min | 303 words

I am in the process of writing an article about RavenDB, and I just wrote the following code to demonstrate RavenDB schema less nature:

using (var session = documentStore.OpenSession())
    session.Store(new Customer
        Name = "Joe Smith",
        Attributes =
                {"IsAnnoyingCustomer", true},
                {"SatisfactionLevel", 8.7},
                {"LicensePlate", "B7D-12JA"}


using (var session = documentStore.OpenSession())
    var customers = session.Query<Customer>()
        .Where(x => x.Attributes["IsAnnoyingCustomer"].Equals(true))



This worked, flawlessly.

The amount of work that we have put into RavenDB to make such things work is really scary when you sit down to think about it.

But it works, it does what I expect it to do and it doesn’t get in my way, woohoo!


Valeriu Caraulean

Are calls to session.SaveChanges(); mandatory here? (I don't know much about RavenDB)

Won't be changes saved when session is disposed?

Matt Warren


No in RavenDB you have to explicitly call .SaveChange(). It triggers a batch upload of docs and commits a transaction, so having it as an explicit call is better.


Do you need that .Equals(true) there for some reason or did you put that in just to be explicit?

Ayende Rahien

Valeriu, We don't save unless you call to SaveChanges(). If you don't need to save, you don't need to call SaveChanges

Ayende Rahien

Configurator, We put the .Equals(true) there because C# would generate a compiler warning about a == between the types.

Henrik Stenbæk

What is the second call to session.SaveChanges(); good for?

Ayende Rahien

Henrik, Nothing, I added it out of habit.

Nathan King

In the Customer class, what is the C# type of the Attiributes property defined as?

Richard Wilde

Does "Joe Smith" come back in the results count? I remember something about it will only be there after it has been indexed and that could take several to several hundred milli-secs


Henrik, Nothing, I added it out of habit.

If there's one thing I always enjoy, it's a confusing 3 line program for a beginners tutorial.

while (;;) { }

Just about as useful as "added it out of habit."

Ayende Rahien

Nathan, Dictionary of string & object


What does the "satisfaction level" refer to lol?


Out of interest, with the second session.SaveChanges(); - would that actually fire off any thing to RavenDb, or would it know there are no changes, and so do nothing?


So RavenDB is designed to enable magic strings, eh? :)

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats