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,317 | Comments: 46,911

filter by tags archive

Certifications: Part II

time to read 2 min | 238 words

So I did 70-316 exam a few hours ago, and I am not really happy about it.

It included questions about setup/deployment, security, localization as well as many questions about using datasets and accessing data. I think there was a single question that I could say related to WinForms: how to stop resizing a form.

Two questions I really dislike:

  • I had to answer with " SET NOCOUNT OFF " - I don't know what it has to do with a Windows based applications, to tell you the truth.
  • Another "memorize the API / Find the difference question". The answers were something along the lines of:
    • foreach(SqlError err in myExp.Errors)
    • foreach(Exception ex in myEmp.Errors)

On the other hand, it does seem more relevant to the windows world, where you don't just use System.Windows.Forms.

After talking to Howard, I decided to take the 70-528 to see what the new certification model has to offer.

TestDriven.Net 2.0 is out, and it is exciting!

time to read 2 min | 219 words

Zero Friction Unit Testing has always been TestDrive.Net strongest point, but with this new release, it bring it to a whole new level.

I feel that some of the new features are made for me, take this one for instnace:

(Image from clipboard).png

That one was a personal request of mine, and I am going to really worn this botton.

There is now integration with a host of new frameworks, from TypeMock to Zanebug. But this isn't something that make me happy. What does make me Happy is this, Reflector integration:

(Image from clipboard).png (Image from clipboard).png

Do you see the value that this is going to bring? Just being able to (so very easily) setup breakpoints in any code that I want is a good idea, and being able to go from 3rd party call ot its source at the press of a key is really impressive. This is going to be a shortcut key the moment I can decide which functionality I need the least (Ctrl+X, Ctrl+C, Ctrl+V).

Orand has all the details about using this.

Great work, Jamie.

User Group Lecture : Summary

time to read 2 min | 269 words

Justin was sick and couldn't make it, but Roy filled in for him with a lecture about Regexes. My lecture was the second one, and I think it went very well. I managed to show everything that I planned to (although not all that I wanted), and actually got to the last slide on time, which was a major worry for me.

Things to improve:

  • This is supposed to be an entry level user group - but I feel that I had answered too many questions at a higher level than may have been appropriate. This was probably because those were good questions, but I probably should have saved
  • It is probably not a good idea to show the SQL code from NHibernate when the dialect is set to SQL 2005 - when you start to use paging scray stuff with CTE are starting to happen, which just confuses people.
  • I noticed mid way that I sometimes get stuck in the middle of explaining a complex concept. This is because to understand the concept you need to understand a whole lot of stuff behind it, which I simply can't explain in a short time frame. As a result, there were several cases where I started a sentence, paused with an "Ah..." and then had to bail out by saying it is too complex.


Bringing it all together: Even More Magic,

time to read 5 min | 936 words

So, I had done a couple of fairly cool stuff recently, but it is all in seperated pieces, let us try to bring them together and see what we get, shall we?

ProjectionQuery<User> query =

       new ProjectionQuery<User>(Where.User.Name.Like("Ayende", MatchMode.Start),

                                 ProjectBy.User.Name && ProjectBy.User.Email);

foreach (object[] objects in query.Execute())


       Console.WriteLine("Name: {0}, Email: {1}", objects[0], objects[1]);


That is nice, isn't it? Again, we can use the strongly typed version to be type safe and avoid the use of arrays as DTO:

ProjectionQuery<User, NameAndEmail> query2 =new ProjectionQuery<User, NameAndEmail>(

       Where.User.Name.Like("Ayende", MatchMode.Start),

       ProjectBy.User.Name && ProjectBy.User.Email);

foreach (NameAndEmail nameAndEmail in query2.Execute())


       Console.WriteLine("Name: {0}, Email: {1}", nameAndEmail.Name, nameAndEmail.Email);


And yes, this is filed under Linq as well.

Projections Support In Active Record

time to read 8 min | 1548 words

Ken, this post if for you...

So, I have been a busy implementing crazy generics stuff and I can show you this:

public class ProjectionQuery<ARType> : ProjectionQuery<ARType, object[]>

Neat class, isn't it?

Please not that this is not the same class that I shows here, that class has been renamed ScalarProjectionQuery, since it better fits its duy.

What can you do with it? Well, things like this:

ProjectionQuery<Blog> proj = new ProjectionQuery<Blog>(
Projections.Property("Name"), Projections.Property("Author"));

IList<object[]> results = proj.Execute();

Assert.AreEqual(blog.Name, results[0][0]);

Assert.AreEqual(blog.Author, results[0][1]);

Now you have got a list or arrays, which contains just the Name and Author from the Blog entity. This used to be much harder and involved writing HQL code (which can be a bummer, since I insist on putting all the HQL code in the mapping files, and not concatenating HQL).

It still has a major issue for me, and that is the fact that I need to work with untyped arrays, not fun, and I simple hate to work with numeric indices. Therefor, let us try this version:

public class ProjectionQuery<ARType, TResultItem> : IActiveRecordQuery

What does this allows me to do? Well, you can write the above snippet of code as:

ProjectionQuery<Blog, KeyValuePair<string, string>> proj = new ProjectionQuery<Blog, KeyValuePair<string, string>>(

               Projections.Property("Name"), Projections.Property("Author"));

IList<KeyValuePair<string, string>> results = proj.Execute();  

Assert.AreEqual(blog.Name, results[0].Key);

Assert.AreEqual(blog.Author, results[0].Value);

Notice that we suddenly have a strongly typed (if generic) way of accessing the information. In fact, in this case, a small, dedicated, class is what I would use. So I could do this:

ProjectionQuery<Blog, NameAndAuthor> proj = new ProjectionQuery<Blog, NameAndAuthor>(

                           Projections.Property("Name"), Projections.Property("Author"));

IList<NameAndAuthor> results = proj.Execute();

Assert.AreEqual(blog.Name, results[0].Name);

Assert.AreEqual(blog.Author, results[0].Author);

Much, much, nicer, in my opinion. :-)

And yes, there is more suprises in the pipeline :-)

NHibernate Query Generator 1.7

time to read 1 min | 145 words

Well, it is certainly an interesting release. This release contains very little code of mine, mainly minor adaptations of two wonderful patches that were sent to me.

  • The first by Bas Jansen - which added inheritance detection from the mapping files.
  • The second by Adam Tybor - which added support for projections and group by.

Me, I just fixed a stupid bug by yours truly that would refuse to recognize exe as valid assemies, and put those two patches together.

Together, they make quite an addition to NQG. Especially when combined with some thing that can really understand projections... which is soon to come.

You can get it here.


  1. RavenDB Conference videos: Zapping ever faster: how Zap sped up by two orders of magnitude using RavenDB - one day from now
  2. Feature intersection bugs are the hardest to predict - about one day from now
  3. RavenDB Conference videos: Implementing CQRS and Event Sourcing with RavenDB - 3 days from now
  4. How did the milk get to the fridge? - 4 days from now
  5. RavenDB Conference videos: Building Codealike: a journey into the developers analytics world - 7 days from now

And 9 more posts are pending...

There are posts all the way to Mar 10, 2017


  1. RavenDB Conference videos (12):
    17 Feb 2017 - Should I use a document database?
  2. Low level Voron optimizations (5):
    20 Feb 2017 - Recyclers do it over and over again.
  3. Implementing low level trie (4):
    26 Jan 2017 - Digging into the C++ impl
  4. Answer (9):
    20 Jan 2017 - What does this code do?
  5. Challenge (48):
    19 Jan 2017 - What does this code do?
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats