April 2010 Entries
NHibernate 3.0 and FluentNHibernate, how to get up and running….

First up. Its actually really easy.

I’m not very religious about my DB tech, I don’t really care, I just want something that works.  So I’m happy to consider all options if they provide an advantage, and recently I was considering jumping from NHibernate to EF 4.0.  However before ditching NHibernate and jumping to EF 4.0 I thought I should try the head version of NHibernates trunk and the Head version of FluentNHibernate.

I currently have a “Repository / Unit of Work” Framework built up around these two techs.  All up it makes my life pretty simple for dealing with databases.   The problem is the current release of NHibernate + the Linq provider wasn’t too hot for our purposes.  Especially trying to plug it into older VB.NET code.   The Linq provider spat the dummy with VB.NET lambdas.  Mainly because in C#

Query().Where(l => l.Name.Contains("x") || l.Name.Contains("y")).ToList();

is not the same as the VB.NET

Query().Where(Function(l) l.Name.Contains("x") Or l.Name.Contains("y")).ToList

VB.NET seems to spit out … well…. something different :-)

so anyways… Compiling your own version of NHibernate and FluentNHibernate.  It’s actually pretty easy!

First you’ll need to install tortisesvn NAnt and Git if you don’t already have them. 


first step, get the subversion trunk

into a directory somewhere.  eg \thirdparty\nhibernate

Then use NAnt to build it.   (if you open the .sln it will show errors in that  AssemblyInfo.cs doesn’t exist )

to build it, there is a .txt document with sample command line build instructions,  I simply used :-

NAnt -D:project.config=release clean build >output-release-build.log

*wait* *wait* *wait* and ta da, you will have a bin directory with all the release dlls.


This was pretty simple.

there’s instructions here :-

basically, with git, create a directory, and you issue the command

git clone git://

and wait, and soon enough you have the source.

Now, from the bin directory that NHibernate spit out, take everything and dump it into the subdirectory “fluent-nhibernate\tools\NHibernate”

Now, to build, you can use rake….which a ruby build system, however you can also just open the solution and build.   Which is what I did.  I had a few problems with the references which I simply re-added using the new ones. 

Once built, I just took all the NHibnerate dlls, and the fluent ones and replaced my existing NHibernate / Fluent and killed off the old linq project.

All I had to change is the places that used  .Linq<T>  and replace them with .Query<T>  (which was easy as I had wrapped it already to isolate my code from such changes)

and hey presto, everything worked.  Even the VB.NET linq calls.

I need to do some more testing as I’ve only done basic smoke tests, but its all looking pretty good, so for now, I will stick to NHibernate! 

Posted On Friday, April 30, 2010 11:37 AM | Comments (4)
Swapping from NHibernate to Entity Framework – Sanity Check

Now I’m not an expert in either of these techs.  I have a nice framework for unit of work / repository built with NHibernate.  Works pretty well.  I use FluentNhibernate to do the mappings.  Works well.  Takes very little code to get going with a DB back OO model.

So why swap?

Linq.  In Entity Framework you get much better linq support. 

Visibility. I have no idea what's really happening with NHibernate….its a cloud of mystery most of the time.  You have to read all the blogs, mailing lists, etc to know what's going on.

So, EF 4.0 looks like pretty good….  it has reasonably good support for mapping POCOs.  Wrapping UnitOfWork and Repository around it seems ok.

Only thing I haven’t liked too much is having to explicitly load lazy loading entities.

So…. am I sane?  is EF the way to go?  or is NHibernate going to suddenly release the next generation of coolness?  Is there any other major gotchas of using EF over NHibernate?

Posted On Thursday, April 29, 2010 2:11 PM | Comments (2)
File Transfer using RDP

I often use RDP to log into servers.   A couple of issues I have had is that its a pain to get files onto the server from my PC at times, and, if there is something missing from the servers windows install, I can’t simply pop the DVD into remote server in some unknown location on the internet somewhere.

The other day I was curious if RDP actually had anything…since it did support shared clipboards, so I went for a look through the options and low and behold, *hidden* away…..

Select Options…


Go to the “Local Resources” Tab, then where it has “Local devices and resources” it sneakily has a “More…” button.


Which then displays a drive selection box.  Select the drive you want ….


Then on your server you will get…..


Nice.  That is useful.

Posted On Monday, April 19, 2010 10:06 PM | Comments (11)

I was wanting to play around with something in a VM the other day.  I was curious what was available for free, if anything, for windows.   I quickly came across Virtual Box  ( ).   Downloaded, Installed. No Problem!  Works really nicely.  

It was commercial software (by sun (now oracle)) that turned open source.  

In terms of a license it says :-

In summary, the VirtualBox PUEL allows you to use VirtualBox free of charge

  • for personal use or, alternatively,
  • for product evaluation.

An interesting feature it has is built in RDP.   Which is useful if you have a guest OS that doesn’t support RDP.  

Speaking of RDP…..  which I will in my next blog post… I learnt something REALLY useful the other day.

Posted On Monday, April 19, 2010 9:52 PM | Comments (0)
Speech Recognition

Today I was asked to write a wee application for someone so that they could turn pages on their ebooks without having to reach for their keyboard or mouse… that way they could do craft or knit or whatever they are doing while they are reading.

I vaguely remember that windows has something built in, but have never really played with it before.   I have in the past turned on the screen reader and impressed my kids by making the computer saying “amusing” phrases along the lines of “Zac has a smelly bum”.

So instead of firing up Visual Studio and getting stuck into the juciy task of writing a speech recognition program…. I typed “speech recognition” into the start menu of my windows 7 computer.   And wow!  I’ve been playing with it for the last 40 minutes or so and have been most impressed.   Dictation wise it certainly misses stuff or gets the wrong words, but I did the training and it certainly improved.

But what I’m enjoying is controlling windows.

for instance, to start this blog entry  I said “Open Writer”  and it worked no problem.    In fact after I muddled my way through getting going with speech recognition I enjoyed saying “Open notepad” … “close”  over and over again.

It allows you to click anywhere on the screen, just say “mousegrid”   and a 1-9 numbered grid comes up,  say a number and it puts a smaller 1-9 numbered grid, and you hone in, till the middle square is on a place you want to click, then you say “click” or “double click”. 

if you want to enter a key, say “Press Tab”  for example.  

inside programs it understands menu entries.  In fact, while writing this I just said “File”  “Save” and it happily saved.

I think I will play around with this for a while more and try it out in visual studio.   Might be quite good for being able to do menu entries instead of grabbing for my mouse…. can keep my hands on the keyboard.

ok, wasn’t the first post I wanted to do on geeks with blogs! but hey…   will do some techy posts soon.

Posted On Monday, April 19, 2010 3:48 AM | Comments (2)