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,128 | Comments: 45,550

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.


  1. The worker pattern - about one day from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  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


Main feed Feed Stats
Comments feed   Comments Feed Stats