• LightSpeed and Eager Loaded properties posted on 20 Jan 2011

    Today Mindscape, the makers of the ORM LightSpeed and other awesome products posted a blog on Lazy-Loading/Eager-Loading properties with LightSpeed.

    Why can't NHibernate do this! And when I say why can't NHibernate do this, I mean, why can't NHibernate do this with Query/QueryOver.

    Ayende detailed this time last year, the ability to lazy-load properties, but currently Query/QueryOver only support One-To-Many and One-To-One relationships.

    NHibernate will support the ability to Lazy-Load a property but you can't specify it to be eager loaded.

    So you do

    Map(x => x.FullDescription).CustomSqlType("NTEXT") 
                               .LazyLoad();
    

    Running a query would result in:

    Great... But you currently cannot do:

    Read more...

  • Revisiting 'Exists' in NHibernate 3.0 and QueryOver posted on 19 Jan 2011

    A while ago I wrote about my experience with NHibernate 3.0 and Query over by having a go at converting an application to NH3.0, and faced the challenge of writing a query which contained an 'exists' where clause. At the time my solution resulted in an 'in' clause since I couldn't work out how to do an exists.

    Today at work I faced the same challenge, except this time I solved it WOO Yay for solving things.

    The Problem

    We have a many-to-many relationship between Jobs and Roles. Which looks something along the lines of:

    I cut a bunch of stuff out but you get the idea.

    Read more...

  • System.Data.SQLite isolationLevel Exception posted on 02 Jan 2011

    I introduced SQLite to our Unit Testing at work to aid with testing the stuff written with NHibernate, most of our repositories are rather simple but some of them require some specific criteria that it would be nice to test our queries work.

    The problem is some of the queries have a transaction with the IsolationLevel as ReadUncommitted.

    Everything works perfectly fine until it comes to testing, the problem is SQLite does not support anything other than Serializable and ReadCommitted.

    I spent a while trying to see if there was a way to have an interceptor for NHibernate to capture the BeginRequest and replace the isolation level with something that would work, when that failed I took a look at extending the SQLite dialect but that just became confusing.

    In the end I reflected the System.Data.SQLite assembly (before i downloaded the sourcecode) to see what was happening when BeginTransaction was being called.

    There's two places it checks, the first is in SQLiteConnection under BeginTransaction:

    if (isolationLevel != IsolationLevel.Serializable && isolationLevel != IsolationLevel.ReadCommitted)
        throw new ArgumentException("isolationLevel");
    

    Read more...

  • Blog Update to WordPress w/ SqlSrv posted on 28 Dec 2010

    Over the past few days I've moved my blog from BlogEngine.Net to WordPress, since BlogEngine is fail.

    I didn't go with a hosted solution since it costs money just to use my own domain name, infact it costs more to use my own domain name than it cost me to register the damn thing. So I investigated blogs and came across:

    http://wordpress.visitmix.com/development/installing-wordpress-on-sql-server

    Seems someone or somepeople have ported wordpress to work on SQL Server, so people who are on Windows with SQL Server and don't want to use FailSQL MySQL can take advantage of wordpress.

    As much as I hate PHP after moving to .Net, the one thing the PHP community did right was all the different CMS and Blog solutions out there, something the .Net community lacks. As far as I'm concerned there is not one good .Net blogging solution available.

    Anyway so far I'm happy with the move.

    Read more...

  • I love clean client IDs - especially with .Net 2.0! posted on 26 Dec 2010

    ASP.Net 4.0 got a brand spanking new feature. Clean ClientID's! ABOUT BLOODY TIME... Only, I'm working on a legacy application which can't be migrated to 4.0 :(

    So why do we need Nice Readable, predictable ClientID's? I can think of two main reasons, outside of that, I would assume you're doing it wrong.

    1. JavaScript, to find elements...
    2. JavaScript in external files where you can't write spaghetti code.

    What do I mean by spaghetti code? I mean this stuff:

    <%= txtUserName.ClientID %>
    <script type="text/javascript">
      var element = $('#<%= txtUserName.ClientID %>');
      var textbox = document.getElementById('<%= txtUserName.ClientID %>');
    </script>
    

    I absolutely detest seeing this sort of thing. It makes me sick, and worst of all you can't pull this sort of code back to an external js file. In Web Forms, spaghetti coding is NOT your presentation, your server control is your presentation, the spaghetti code is your binding, and this should be in the codebehind.

    Read more...

  • Moq-Using Params in the Returns posted on 06 Dec 2010

    Had an interesting scenario to solve today, while I was away a bunch of unit tests got turned off since they broke during some refactoring, I spent the day fixing theses unit tests.

    The method under test had a dependency on another class, it performed two actions on this class.

    1. to get a list of data
    2. to return a DateRange (this is done in a foreach loop)

    DateRange is just a class with a start/end property of DateTime. The method is sort of like this (obviously with proper names I just wrote some random code to illustrate the scenario)

    public IEnumerable<Stuff> GetStuff(DateTime dateList)
    {
        var result = new List<Stuff>();
        var someService = IoC.Resolve<ISomeService>();
        var data = someService.GetData();
    
        foreach (var date in dateList)
        {
            var tempDate = date;
            DateRange range = someService.GetDates(OpenRules, tempDate);
            //do stuff...
        }
    
        return result;
    }
    

    So the same service is called twice, the issue is when iterating over the dateList, it needs to be filtered based on a DateRange during the day. So say, 8am till 10pm. Removing the stuff outside of that time period during that day.

    Read more...

  • Yay for NHibernate 3.0 posted on 05 Dec 2010

    So happy. NHibernate 3.0 just got released.

    http://nhforge.org/blogs/nhibernate/archive/2010/12/05/nhibernate-3-0-released.aspx

    Now to wait for Fluent to be updated and a repository to be shoved on NuGet.

    Read more...

  • Sydney Alt.Net with Udi Dahan and NServiceBus Commercial Support posted on 01 Dec 2010

    Note: Update 31-12-2012 - This is a really old post and the licensing described in here no longer applies. Please visit http://nservicebus.com/

    Last night I attended the Sydney Alt.Net user group since Udi Dahan was attending. There was no specific topic, it was an open questions/answers session with Udi. If you're interested you can watch it here.

    The thing that interested me most was to do with NServiceBus commercial support (1 hour 23 minutes in the video if you want to skip ahead). Initially I thought that it was going from Open Source to requiring a license, a license I wouldn't be able to afford for my hobby projects, however someone asked about the licensing.

    Read more...

  • Mentally Drained by Udi Dahan. posted on 27 Nov 2010

    I'm on my first day of recovery after attending Udi Dahan's Advanced Distributed Systems Design using SOA & DDD. Needless to say I think I'm still in shock.

    Udi must be one of the best presenters I've come across, I always thought he talked a little slow when watching videos of him presenting, but it's an entirely different experience when you're sitting in a room listening to him.

    He really makes sure you follow and understand, at no point did I feel like I was left behind. Something that intrigued me however, was there was not one question he could not answer... He must have heard every possible question because people started trying to catch him out with some weird example or scenario, and he was able to answer it.

    Read more...

  • Failware... aka,MSN posted on 28 Oct 2010

    Microsoft recently pushed out a Windows Update for their Windows Live Essentials, in this update came Windows Live Messenger.

    Wow... what was the Windows Live team thinking when they wrote this? It's the biggest pile of crap ever.

    The progression of MSN was fine, sure it was becoming slight bloatware, has some annoying advertising, and some silly features. But it worked well and looked nice.

    My biggest pet hate?

    If I sent a link to an image, I'm sending a god damn LINK. If I wanted to send an image, I would send an image. But I'm not, I'm sending a LINK.

    Read more...