Thursday, May 3, 2012

And sometimes Things Just Works

And sometimes Things Just Works:
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"}
}
});

session.SaveChanges();
}

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

Console.WriteLine(customers.Count);

session.SaveChanges();
}



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!


ICT4PE&D

No comments:

Post a Comment

Thank's!