<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
    <channel>
        <title>The Darkside</title>
        <link>http://www.darkside.co.za/Default.aspx</link>
        <description>Shedding light on things and stuff</description>
        <language>en-ZA</language>
        <copyright>Ryan Schreiber</copyright>
        <generator>Subtext Version 2.1.0.5</generator>
        <image>
            <title>The Darkside</title>
            <url>http://www.darkside.co.za/images/RSS2Image.gif</url>
            <link>http://www.darkside.co.za/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/darksidethingsandstuff" /><feedburner:info uri="darksidethingsandstuff" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
            <title>Constructing a large OR statement in Castle ActiveRecord</title>
            <category>ActiveRecord</category>
            <link>http://www.darkside.co.za/archive/2012/01/20/large-or-statement-castle-activerecord.aspx</link>
            <description>&lt;p&gt;Wow – it seems like last year just flew by. I opened LiveWriter this morning and realised that I last posted an article in June 2011, and that I have 14 incomplete articles that I’ve never got round to completing.&lt;/p&gt;  &lt;p&gt;To kick off the year, I’m going to start off with (what I think) is an underused class in Castle ActiveRecord (actually, it resides from NHibernate) – &lt;font color="#2b91af" face="Courier New"&gt;Disjunction&lt;/font&gt;. &lt;/p&gt;  &lt;p&gt;The Disjunction type can be used to construct large 'OR' statements for use in ActiveRecord data retrievals. If you have used this class before, you may have noticed that any ‘OR’ operations that have more than two boolean operation that you’ve wanted to perform end up looking like this:&lt;/p&gt;  &lt;div class="Code"&gt;   &lt;pre style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;var&lt;/span&gt; criteria = &lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Or&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        (&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Or(&lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Firstname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Foo"&lt;/span&gt;), &lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Lastname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Foo"&lt;/span&gt;)),&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Or(&lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Firstname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Bar"&lt;/span&gt;), &lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Lastname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Bar"&lt;/span&gt;))&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        );&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;var&lt;/span&gt; person = &lt;span style="color: #2b91af"&gt;Person&lt;/span&gt;.FindAll(criteria);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The example above ends up producing some unnecessary code clutter to essentially come up with the SQL statement:&lt;/p&gt;

&lt;div class="Code"&gt;
  &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;WHERE&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;   &lt;span style="color: teal"&gt;Firstname&lt;/span&gt; &lt;span style="color: gray"&gt;LIKE&lt;/span&gt; &lt;span style="color: red"&gt;'%Foo%'&lt;/span&gt; &lt;span style="color: gray"&gt;OR&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;   &lt;span style="color: teal"&gt;Firstname&lt;/span&gt; &lt;span style="color: gray"&gt;LIKE&lt;/span&gt; &lt;span style="color: red"&gt;'%Bar%'&lt;/span&gt; &lt;span style="color: gray"&gt;OR&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;   &lt;span style="color: teal"&gt;Lastname&lt;/span&gt;  &lt;span style="color: gray"&gt;LIKE&lt;/span&gt; &lt;span style="color: red"&gt;'%Foo%'&lt;/span&gt; &lt;span style="color: gray"&gt;OR&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;   &lt;span style="color: teal"&gt;Lastname&lt;/span&gt;  &lt;span style="color: gray"&gt;LIKE&lt;/span&gt; &lt;span style="color: red"&gt;'%Bar%'&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Using the Disjunction class, you can modify the original example to look like this:&lt;/p&gt;

&lt;div class="Code"&gt;
  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: blue"&gt;var&lt;/span&gt; criteria = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Disjunction&lt;/span&gt;();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            criteria.Add(&lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Firstname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Foo"&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            criteria.Add(&lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Firstname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Bar"&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            criteria.Add(&lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Lastname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Foo"&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            criteria.Add(&lt;span style="color: #2b91af"&gt;Restrictions&lt;/span&gt;.Like(&lt;span style="color: #a31515"&gt;"Lastname"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"Bar"&lt;/span&gt;));&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: blue"&gt;var&lt;/span&gt; person = &lt;span style="color: #2b91af"&gt;Person&lt;/span&gt;.FindAll(criteria);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In my opinion: better looking code and, although it’s not quite made evident in the examples above, it makes for much easier programming. Image that you were searching 5 fields for three keywords – the “tree” that you’ve effectively built in the first example would start looking horrendous and would be a nightmare to maintain.&lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/125.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2012/01/20/large-or-statement-castle-activerecord.aspx</guid>
            <pubDate>Fri, 20 Jan 2012 06:53:13 GMT</pubDate>
            <wfw:comment>http://www.darkside.co.za/comments/125.aspx</wfw:comment>
            <comments>http://www.darkside.co.za/archive/2012/01/20/large-or-statement-castle-activerecord.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/125.aspx</wfw:commentRss>
        </item>
        <item>
            <title>A relook at my Windows service template project</title>
            <category>Development</category>
            <link>http://www.darkside.co.za/archive/2011/06/07/another-windows-service-template.aspx</link>
            <description>&lt;p&gt;A while ago I &lt;a title="A Simple Windows Service Template" href="http://www.darkside.co.za/archive/2009/02/11/simple-windows-service-template.aspx" target="_blank"&gt;blogged about a template project&lt;/a&gt; that I often use as my starting point for Windows services. I’ve recently been introduced to a component called &lt;a title="Topshelf" href="http://topshelf-project.com/" target="_blank"&gt;TopShelf&lt;/a&gt; that makes writing a service even simpler as well as taking just about all the plumbing code needed for installing/uninstalling and running in debug mode.&lt;/p&gt;  &lt;p&gt;Here’s an example of the code that goes into the Main method. It sets up the service, name, description, and you tell it what to call on the Start and Stop service control events. &lt;/p&gt;  &lt;div class="CodeCollapse"&gt;   &lt;pre style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Main(&lt;span style="color: blue"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: blue"&gt;const&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; name = &lt;span style="color: #a31515"&gt;"My Service Host"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: blue"&gt;const&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; description = &lt;span style="color: #a31515"&gt;"My Service Host Description"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: blue"&gt;var&lt;/span&gt; host = &lt;span style="color: #2b91af"&gt;HostFactory&lt;/span&gt;.New(configuration =&amp;gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                configuration.Service&amp;lt;&lt;span style="color: #2b91af"&gt;ServiceHostControl&lt;/span&gt;&amp;gt;(&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                    callback =&amp;gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                    {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                        callback.SetServiceName(name);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                        callback.ConstructUsing(s =&amp;gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ServiceHostControl&lt;/span&gt;());&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                        callback.WhenStarted(service =&amp;gt; service.Start());&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                        callback.WhenStopped(service =&amp;gt; service.Stop());&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                    });&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                configuration.SetDisplayName(name);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                configuration.SetServiceName(name);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                configuration.SetDescription(description);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                configuration.DependsOnMsSql(); &lt;span style="color: green"&gt;//Just here as an example of some of the features&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                configuration.RunAsLocalService();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            });&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            host.Run();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        }&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;I make reference in the code above to a class called ServiceHostControl. This class is the only other code I have in my template project as of now – it provides the stub methods for starting and stopping the service.&lt;/p&gt;

&lt;div class="CodeCollapse"&gt;
  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;internal&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ServiceHostControl&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Start()&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"starting..."&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: green"&gt;//Do everything here to start up the service...&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"started."&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Stop()&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"stopping..."&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: green"&gt;//Do everything here to shut the service down...&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"stopped."&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    }&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;There is no longer a need to have a service installer class anymore either in the project – all this functionality is brought to the party by the Topshelf component. To install your service, you simply drop to a command prompt and type in:&lt;/p&gt;

&lt;div class="Code"&gt;
  &lt;p&gt;&lt;strong&gt;{serviceassembly.exe} install&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;and (as you can most likely guess) to uninstall, you type in:&lt;/p&gt;

&lt;div class="Code"&gt;
  &lt;p&gt;&lt;strong&gt;{serviceassembly.exe} uninstall&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;It’s as simple as that.&lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/122.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2011/06/07/another-windows-service-template.aspx</guid>
            <pubDate>Tue, 07 Jun 2011 09:00:15 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2011/06/07/another-windows-service-template.aspx#feedback</comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/122.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Restarting ReSharper in the IDE</title>
            <category>General</category>
            <link>http://www.darkside.co.za/archive/2011/05/12/restart-resharper-in-ide.aspx</link>
            <description>&lt;p&gt;This is just a quick tip that you can use to restart ReSharper in Visual Studio (without restarting the IDE) if it becomes unresponsive. In my case, it just disappears from view and the majority of my shortcuts stop working.&lt;/p&gt;  &lt;p&gt;Open the immediate window, either through the menu “Debug-&amp;gt;Windows-&amp;gt;Immediate” or using the keyboard shortcut “Ctl-Alt-I”.&lt;/p&gt;  &lt;p&gt;Type in: &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;gt;ReSharper_Suspend&lt;/strong&gt; press enter, and then &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;gt;ReSharper_Resume&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You must type the “&lt;strong&gt;&amp;gt;&lt;/strong&gt;” first to be able to enter commands in the immediate window. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Some other notes:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;You can use the command window as well (just leave out the angle bracket), however, I find that the shortcut “Ctl-Alt-A” often breaks when ReSharper is broken. Moving my hand to my mouse is an effort :) &lt;/li&gt;    &lt;li&gt;You could also use the command “ReSharper_ToggleSuspended” twice in a row; You just have to keep swapping to a code window to test it out. &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://www.darkside.co.za/aggbug/121.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2011/05/12/restart-resharper-in-ide.aspx</guid>
            <pubDate>Thu, 12 May 2011 07:22:46 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2011/05/12/restart-resharper-in-ide.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/121.aspx</wfw:commentRss>
        </item>
        <item>
            <title>An alternative to Reflector - ILSpy</title>
            <category>General</category>
            <link>http://www.darkside.co.za/archive/2011/04/04/alternative-to-reflector-ilspy.aspx</link>
            <description>&lt;p&gt;I’ve been contemplating the fact that Reflector is no longer a free tool, and paying the $35 (USD) for the tool. I’ll be honest: paying for software has &lt;em&gt;never&lt;/em&gt; been an issue for me. I even use SQL Prompt from RedGate. I write software, and need to get paid for it, for a living.&lt;/p&gt;  &lt;p&gt;But…&lt;/p&gt;  &lt;p&gt;The fact that RedGate said that they would continue offering Reflector for free and did an about turn on it has riled me a tad. They haven’t even offered existing users a “this-is-the-final-free-version-and-will-never-get-updated” option. Sad.&lt;/p&gt;  &lt;p&gt;I went through the suggestions from this &lt;a href="http://stackoverflow.com/questions/2425973/open-source-alternatives-to-reflector" target="_blank"&gt;Stack Overflow&lt;/a&gt; article, and personally feel that &lt;a href="http://wiki.sharpdevelop.net/ILSpy.ashx" target="_blank"&gt;ILSpy&lt;/a&gt; is the best alternative.&lt;/p&gt;  &lt;p&gt;Here’s the list (copied from the summary from the article above):&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;a href="http://cciast.codeplex.com/" rel="nofollow" target="_blank"&gt;Common Compiler Infrastructure&lt;/a&gt; (CCI) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.mono-project.com/Cecil" rel="nofollow" target="_blank"&gt;Mono Cecil&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://wiki.sharpdevelop.net/ILSpy.ashx" rel="nofollow" target="_blank"&gt;ILSpy&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sites.google.com/site/kalirosupport/home" rel="nofollow" target="_blank"&gt;Kaliro&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sourceforge.net/projects/dile/" rel="nofollow" target="_blank"&gt;Dotnet IL Editor (DILE)&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="https://github.com/jcdickinson/Monoflector" rel="nofollow" target="_blank"&gt;Monoflector&lt;/a&gt; (&lt;a href="http://twitter.com/#!/jcdickinson/status/54874110811058176" rel="nofollow" target="_blank"&gt;no longer active&lt;/a&gt; as of April 2011) &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Try them out – see what you think…&lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/120.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2011/04/04/alternative-to-reflector-ilspy.aspx</guid>
            <pubDate>Mon, 04 Apr 2011 19:35:37 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2011/04/04/alternative-to-reflector-ilspy.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/120.aspx</wfw:commentRss>
        </item>
        <item>
            <title>What&amp;rsquo;s new in Castle ActiveRecord 3 RC?</title>
            <category>ActiveRecord</category>
            <category>Development</category>
            <link>http://www.darkside.co.za/archive/2011/03/30/whats-new-castle-activerecord-3.aspx</link>
            <description>&lt;h1&gt;Configuration&lt;/h1&gt;  &lt;p&gt;Version 3 now supports the short-hand configuration options supplied by NHibernate. You choose the DB type, supply a connection string name, and the rest of the defaults are chosen for you.&lt;/p&gt;  &lt;div class="Code"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configSections&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;section&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;activerecord&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;configSections&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;ARTest&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Server=(local); Database=ComplexDBTest; Integrated Security=SSPI&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;activerecord&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;config&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;db&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;MsSqlServer2005&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;csn&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;ARTest&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;activerecord&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;h1&gt;SessionScope-less Lazy Loading&lt;/h1&gt;  &lt;p&gt;This is a great change that’s been implemented. The code example below (very contrived, I know, but demonstrates the point) used to throw an exception, but doesn’t anymore. &lt;/p&gt;  &lt;div class="Code"&gt;   &lt;p style="margin: 0px"&gt;    [&lt;span style="color: #2b91af"&gt;ActiveRecord&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"Person"&lt;/span&gt;, Lazy = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;partial&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Person&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ActiveRecordBase&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Person&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        [&lt;span style="color: #2b91af"&gt;PrimaryKey&lt;/span&gt;(Generator = &lt;span style="color: #2b91af"&gt;PrimaryKeyType&lt;/span&gt;.GuidComb, Column = &lt;span style="color: #a31515"&gt;"PersonId"&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;virtual&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt; Id { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        [&lt;span style="color: #2b91af"&gt;HasMany&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;ContactNumber&lt;/span&gt;), Table = &lt;span style="color: #a31515"&gt;"ContactNumbers"&lt;/span&gt;, ColumnKey = &lt;span style="color: #a31515"&gt;"PersonId"&lt;/span&gt;, Lazy = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;virtual&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ContactNumber&lt;/span&gt;&amp;gt; PersonIdContactNumbersList { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;    [&lt;span style="color: #2b91af"&gt;ActiveRecord&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"ContactNumber"&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;partial&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ContactNumber&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ActiveRecordBase&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ContactNumber&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        [&lt;span style="color: #2b91af"&gt;PrimaryKey&lt;/span&gt;(Generator = &lt;span style="color: #2b91af"&gt;PrimaryKeyType&lt;/span&gt;.GuidComb, Column = &lt;span style="color: #a31515"&gt;"ContactNumberId"&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;virtual&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt; Id { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;        [&lt;span style="color: #2b91af"&gt;BelongsTo&lt;/span&gt;(Type = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Person&lt;/span&gt;), Column = &lt;span style="color: #a31515"&gt;"PersonId"&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;virtual&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Person&lt;/span&gt; Person { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    } &lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Program&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Main(&lt;span style="color: blue"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;            &lt;span style="color: #2b91af"&gt;ActiveRecordStarter&lt;/span&gt;.Initialize(&lt;span style="color: #2b91af"&gt;Assembly&lt;/span&gt;.GetExecutingAssembly(), &lt;span style="color: #2b91af"&gt;ActiveRecordSectionHandler&lt;/span&gt;.Instance);&lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt; &lt;/p&gt;    &lt;p style="margin: 0px"&gt;            &lt;span style="color: #2b91af"&gt;ContactNumber&lt;/span&gt; contactNumber;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;            &lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SessionScope&lt;/span&gt;())&lt;/p&gt;    &lt;p style="margin: 0px"&gt;            {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;                contactNumber = &lt;span style="color: #2b91af"&gt;ContactNumber&lt;/span&gt;.FindFirst(&lt;span style="color: #2b91af"&gt;Order&lt;/span&gt;.Asc(&lt;span style="color: #a31515"&gt;"Id"&lt;/span&gt;));&lt;/p&gt;    &lt;p style="margin: 0px"&gt;            }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;            &lt;span style="color: #2b91af"&gt;Debug&lt;/span&gt;.WriteLine(contactNumber.Person.Id); &lt;span style="color: green"&gt;//Used to throw an exception&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        }&lt;/p&gt;    &lt;p style="margin: 0px"&gt;    }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;Make sure that in your configuration, (if you’re still specifying the entire config) you’re using the Castle.ActiveRecord.ByteCode.ProxyFactoryFactory proxy factory.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;h1&gt;Lazy Loading of Blob Properties&lt;/h1&gt;  &lt;p&gt;You can now use the “Lazy” keyword on blob properties which tells NHibernate not to include this column in the select statement, but only call it when it’s explicitly used. Some notes on this, though: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;If you have more than one column marked as lazy, they are ALL fetched when you access the first one. &lt;/li&gt;    &lt;li&gt;The property should be an auto-prop &lt;/li&gt;    &lt;li&gt;This results in and extra select being fired off when you used this column – it may end up being a problem in large sets of data.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The syntax is straight forward:&lt;/p&gt;  &lt;div class="Code"&gt;   &lt;p style="margin: 0px"&gt;        [&lt;span style="color: #2b91af"&gt;Property&lt;/span&gt; (Column =&lt;span style="color: #a31515"&gt;"Data"&lt;/span&gt;, ColumnType = &lt;span style="color: #a31515"&gt;"BinaryBlob"&lt;/span&gt; , Lazy = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;virtual&lt;/span&gt; &lt;span style="color: blue"&gt;byte&lt;/span&gt;[] Data { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt; &lt;/p&gt;  &lt;h1&gt;LINQ&lt;/h1&gt;  &lt;p&gt;LINQ support is now rolled into the Castle ActiveRecord assembly, and doesn’t require a reference to another file.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;h1&gt;SessionScopeWebModule (Breaking Change)&lt;/h1&gt;  &lt;p&gt;This has been removed from the main Castle ActiveRecord assembly and is now in the assembly Castle.ActiveRecord.Web.dll. You’ll need to update your configuration for the HttpModule as follows:&lt;/p&gt;  &lt;div class="Code"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;httpModules&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;ARScope&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Castle.ActiveRecord.Framework.SessionScopeWebModule, Castle.ActiveRecord.Web&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: blue"&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;httpModules&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;&lt;img src="http://www.darkside.co.za/aggbug/119.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2011/03/30/whats-new-castle-activerecord-3.aspx</guid>
            <pubDate>Wed, 30 Mar 2011 10:37:46 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2011/03/30/whats-new-castle-activerecord-3.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/119.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SqlDependency Helper Class</title>
            <category>SQL</category>
            <category>Development</category>
            <link>http://www.darkside.co.za/archive/2011/02/11/sqldependency-helper-class.aspx</link>
            <description>&lt;p&gt;It’s been a while since I used the SqlDependency class and the features it provides, and was then quite disappointed that I hadn’t a copy of the plumbing code anywhere on my web clipboard (a.k.a darkside.co.za). I’ve put together a static helper class that you can attach an event to, and then call the Start(…) method. &lt;/p&gt;  &lt;p&gt;Here is the code for the class (&lt;strong&gt;UPDATE: &lt;/strong&gt;or you can &lt;a href="http://www.darkside.co.za/files/SqlNotificationHelper.zip" target="_blank"&gt;download it here&lt;/a&gt;):&lt;/p&gt;  &lt;div class="CodeCollapse"&gt;   &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    1&lt;/span&gt; &lt;span style="color: blue"&gt;using&lt;/span&gt; System.Data;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    2&lt;/span&gt; &lt;span style="color: blue"&gt;using&lt;/span&gt; System.Data.SqlClient;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    3&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    4&lt;/span&gt; &lt;span style="color: blue"&gt;namespace&lt;/span&gt; Darkside&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    5&lt;/span&gt; {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    6&lt;/span&gt;     &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlNotificationHelper&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    7&lt;/span&gt;     {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    8&lt;/span&gt;         &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt; m_SqlConnection;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;    9&lt;/span&gt;         &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlCommand&lt;/span&gt; m_SqlCommand;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   10&lt;/span&gt;         &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DataSet&lt;/span&gt; m_DataSet;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   11&lt;/span&gt;         &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; m_ConnectionString;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   12&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   13&lt;/span&gt;         &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;delegate&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DataChanged&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;DataSet&lt;/span&gt; dataSet);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   14&lt;/span&gt;         &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;event&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DataChanged&lt;/span&gt; DataChangedEvent;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   15&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   16&lt;/span&gt;         &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Start(&lt;span style="color: blue"&gt;string&lt;/span&gt; connectionString, &lt;span style="color: blue"&gt;string&lt;/span&gt; sql, &lt;span style="color: #2b91af"&gt;CommandType&lt;/span&gt; commandType)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   17&lt;/span&gt;         {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   18&lt;/span&gt;             m_ConnectionString = connectionString;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   19&lt;/span&gt;             &lt;span style="color: #2b91af"&gt;SqlDependency&lt;/span&gt;.Stop(m_ConnectionString);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   20&lt;/span&gt;             &lt;span style="color: #2b91af"&gt;SqlDependency&lt;/span&gt;.Start(m_ConnectionString);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   21&lt;/span&gt;             &lt;span style="color: blue"&gt;if&lt;/span&gt; (m_SqlConnection == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   22&lt;/span&gt;                 m_SqlConnection = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt;(m_ConnectionString);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   23&lt;/span&gt;             &lt;span style="color: blue"&gt;if&lt;/span&gt; (m_SqlCommand == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   24&lt;/span&gt;                 m_SqlCommand = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlCommand&lt;/span&gt;(sql, m_SqlConnection) { CommandType = commandType };&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   25&lt;/span&gt;             &lt;span style="color: blue"&gt;if&lt;/span&gt; (m_DataSet == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   26&lt;/span&gt;                 m_DataSet = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DataSet&lt;/span&gt;();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   27&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   28&lt;/span&gt;             SetupNotification();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   29&lt;/span&gt;         }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   30&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   31&lt;/span&gt;         &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Stop()&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   32&lt;/span&gt;         {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   33&lt;/span&gt;             &lt;span style="color: #2b91af"&gt;SqlDependency&lt;/span&gt;.Stop(m_ConnectionString);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   34&lt;/span&gt;             &lt;span style="color: blue"&gt;if&lt;/span&gt; (m_SqlConnection != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   35&lt;/span&gt;                 m_SqlConnection.Close();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   36&lt;/span&gt;         }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   37&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   38&lt;/span&gt;         &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; SqlDependencyOnChange(&lt;span style="color: blue"&gt;object&lt;/span&gt; sender, &lt;span style="color: #2b91af"&gt;SqlNotificationEventArgs&lt;/span&gt; e)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   39&lt;/span&gt;         {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   40&lt;/span&gt;             &lt;span style="color: blue"&gt;var&lt;/span&gt; sqlDependency = sender &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlDependency&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   41&lt;/span&gt;             &lt;span style="color: blue"&gt;if&lt;/span&gt; (sqlDependency != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   42&lt;/span&gt;                 sqlDependency.OnChange -= SqlDependencyOnChange;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   43&lt;/span&gt;             SetupNotification();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   44&lt;/span&gt;             &lt;span style="color: blue"&gt;if&lt;/span&gt; (DataChangedEvent != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   45&lt;/span&gt;                 DataChangedEvent(m_DataSet);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   46&lt;/span&gt;         }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   47&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   48&lt;/span&gt;         &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; SetupNotification()&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   49&lt;/span&gt;         {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   50&lt;/span&gt;             m_DataSet.Clear();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   51&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   52&lt;/span&gt;             m_SqlCommand.Notification = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   53&lt;/span&gt;             &lt;span style="color: blue"&gt;var&lt;/span&gt; sqlDependency = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlDependency&lt;/span&gt;(m_SqlCommand);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   54&lt;/span&gt;             sqlDependency.OnChange += SqlDependencyOnChange;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   55&lt;/span&gt;             &lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: blue"&gt;var&lt;/span&gt; adapter = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlDataAdapter&lt;/span&gt;(m_SqlCommand))&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   56&lt;/span&gt;             {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   57&lt;/span&gt;                 adapter.Fill(m_DataSet, &lt;span style="color: #a31515"&gt;"DataSet"&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   58&lt;/span&gt;             }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   59&lt;/span&gt;         }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   60&lt;/span&gt;     }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   61&lt;/span&gt; }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   62&lt;/span&gt; &lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;And you can use it as follows:&lt;/p&gt;

&lt;div class="Code"&gt;
  &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;protected&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Main()&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: #2b91af"&gt;SqlNotificationHelper&lt;/span&gt;.DataChangedEvent += &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlNotificationHelper&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;DataChanged&lt;/span&gt;(SqlNotificationHelper_DataChangedEvent);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: #2b91af"&gt;SqlNotificationHelper&lt;/span&gt;.Start(&lt;span style="color: #a31515"&gt;"Server=(local); Database=Test; Integrated Security=SSPI"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"SELECT Id, FirstName, Surname FROM dbo.People"&lt;/span&gt;, &lt;span style="color: #2b91af"&gt;CommandType&lt;/span&gt;.Text);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.ReadLine();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; SqlNotificationHelper_DataChangedEvent(System.Data.&lt;span style="color: #2b91af"&gt;DataSet&lt;/span&gt; dataSet)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Event – Data Updated."&lt;/span&gt; + dataSet.Tables[0].Rows.Count);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;I should point out that you need to be quite specific in the type of query that you use. The list contained &lt;a title="Creating a Query for Notification" href="http://msdn.microsoft.com/en-us/library/ms181122(SQL.100).aspx" target="_blank"&gt;here on MSDN&lt;/a&gt; is quite comprehensive. The most common pitfalls I can imagine will befall people is using a * in the SELECT statement, and not specifying the table name in two-part format. The change event still fires even if the query isn’t correct, however, it fires repeatedly and can be quite a pain to debug.&lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/118.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2011/02/11/sqldependency-helper-class.aspx</guid>
            <pubDate>Fri, 11 Feb 2011 09:52:45 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2011/02/11/sqldependency-helper-class.aspx#feedback</comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/118.aspx</wfw:commentRss>
        </item>
        <item>
            <title>A C# Regular Expression for a GUID</title>
            <category>General</category>
            <category>Development</category>
            <link>http://www.darkside.co.za/archive/2010/09/03/regex-guid.aspx</link>
            <description>&lt;p&gt;I’ve been searching for a good regular expression to validate a string representation of a GUID, and even though there are 17 results on &lt;a title="GUID search on RegExLib.com" href="http://www.regexlib.com/Search.aspx?k=guid" target="_blank"&gt;RegExLib.com&lt;/a&gt; and 73000+ on Google, I’ve not found one that matches the start and end braces correctly. Every single one I’ve found (without exaggerating, I read over 60 posts while looking)either matches a GUID without the braces, or those that match on a string including the braces allow for either only the first or last to be present.&lt;/p&gt;  &lt;div class="Code"&gt;^(?&amp;lt;-BRACE&amp;gt;\{)?[a-fA-F\d]{8}-(?:[a-fA-F\d]{4}-){3}[a-fA-F\d]{12}(?&amp;lt;-BRACE&amp;gt;\})?(?(BRACE)^.)$ &lt;/div&gt;  &lt;p&gt;On a side note: The project I’m doing maintenance on is VS2008/.Net 3.5. If you’re using .Net Framework 4, you can use the Guid.Parse and Guid.TryParse methods to validate a Guid.&lt;/p&gt;  &lt;p&gt;UPDATE: I’ve submitted it to &lt;a title="My Guid Regex" href="http://www.regexlib.com/REDetails.aspx?regexp_id=3112" target="_blank"&gt;RegExLib.com&lt;/a&gt;. &lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/117.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2010/09/03/regex-guid.aspx</guid>
            <pubDate>Fri, 03 Sep 2010 09:53:17 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2010/09/03/regex-guid.aspx#feedback</comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/117.aspx</wfw:commentRss>
        </item>
        <item>
            <title>T4 Text Template for Castle ActiveRecord</title>
            <category>ActiveRecord</category>
            <category>SQL</category>
            <category>Development</category>
            <link>http://www.darkside.co.za/archive/2010/08/18/t4-text-template-castle-activerecord.aspx</link>
            <description>&lt;p&gt;I was busy with a(nother) comparison of Castle ActiveRecord and the Microsoft offerings that have shipped with VS2010 just to make sure that I wasn’t missing out on anything. I ended up fiddling with EDMX files, and then custom generation, which then led me to downloading the ADO.Net POCO T4 generation templates and checking out what was in the files. &lt;/p&gt;
&lt;p&gt;I have to admit: when I saw what was in it, I got quite giddy with excitement, followed shortly by feeling like a tool. I can’t believe I’ve missed out on this excellent piece of functionality that has been around for ages. &lt;/p&gt;
&lt;p&gt;I decided to tackle making a template that generated output that matched what is generated by &lt;a target="_blank" href="http://generatorstudio.codeplex.com/"&gt;Generator Studio&lt;/a&gt;, which is an open source project I started with &lt;a target="_blank" href="http://www.fryhard.com/"&gt;FryHard&lt;/a&gt; a few years back, primarily to generate my ActiveRecord classes from my database model. I based my template on the ADO.Net POCO template from Microsoft and used it as my guideline.&lt;/p&gt;
&lt;p&gt;Explaining the code in the TT file is a little out of the scope of this article, but it is &lt;a title="Darkside Castle ActiveRecord CodeGen Template" target="_blank" href="http://www.darkside.co.za/files/DarksideCastleActiveRecordTemplate.zip"&gt;available here for download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can paste the zip file in&lt;/p&gt;
&lt;div class="Code"&gt;%userprofile%\Documents\Visual Studio 2010\Templates\ItemTemplates\Visual C#\ &lt;/div&gt;
&lt;p&gt;and then open the Visual Studio Command Prompt (as Administrator) and run:&lt;/p&gt;
&lt;div class="Code"&gt;devenv /installvstemplates &lt;/div&gt;
&lt;p&gt;The command above installs the new templates for Visual Studio.&lt;/p&gt;
&lt;p&gt;The quickest way to use it in much the same way as a generator is as follows:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Create a new class library or windows app project. &lt;/li&gt;
    &lt;li&gt;Add a reference to Castle.ActiveRecord.&lt;/li&gt;
    &lt;li&gt;Add an ADO.NET Entity Data Model to your project. &lt;/li&gt;
    &lt;li&gt;Choose the “Generate from Database” option in the wizard&lt;/li&gt;
    &lt;li&gt;Run through the rest of the wizard adding the tables you’d like to generate ActiveRecord classes from.&lt;/li&gt;
    &lt;li&gt;Open the entity model in the IDE, and change the “Code Generation Strategy” property in the properties tab to “None”. This remove all code from the designer class attached to the EDMX file.&lt;/li&gt;
    &lt;li&gt;Add a new “Castle ActiveRecord Basic Template” item to your project. This is the template contained in the download above. &lt;/li&gt;
    &lt;li&gt;Once the template has been added, you can look at the files generated by it, and there should be 1 each for each table in your database, as well as an additional file that has the same name as the template (except with a .CS extension), that has no functionality in it. This is created by the template (as it was in the original from MS), and I’ve left it there because I’ll most likely use for custom features/base classes as I build on the template.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You should now be able to use the ActiveRecord classes generated as you normally would. &lt;/p&gt;
&lt;p&gt;If you make changes to your model in the EDMX designer, you can simply right-click on the template file in the solution and select the “Run Custom Tool” to regenerate your classes.&lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/116.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2010/08/18/t4-text-template-castle-activerecord.aspx</guid>
            <pubDate>Wed, 18 Aug 2010 09:32:35 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2010/08/18/t4-text-template-castle-activerecord.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/116.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Initialising Castle ActiveRecord in a WAS-hosted WCF service</title>
            <category>ActiveRecord</category>
            <category>Development</category>
            <category>WCF</category>
            <link>http://www.darkside.co.za/archive/2010/07/16/initialise-castle-activerecord-was-wcf.aspx</link>
            <description>&lt;p&gt;I stumbled upon an interesting problem this morning where Castle ActiveRecord was being initialised correctly in the development environment, but as soon as everything was rolled out to the lab environment, the application would throw errors about AR not being initialised. The error message was along the lines of:&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000" face="Courier New"&gt;An ActiveRecord class (Darkside.Domain.Person) was used but the framework seems not properly initialized. Did you forget about ActiveRecordStarter.Initialize() ?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;A bit of background info: As is custom in our web projects, we use an HttpModule to do the AR initialisation. In this case, the web project is actually a WAS host for our WCF services. After doing a bit of research, I found out that HttpModules are not executed when running WCF services. The reason we had the illusion it was working in dev is because of a default page that was started when the project was run. This caused the HttpModule to run, which in turn initialised AR for that session.&lt;/p&gt;  &lt;p&gt;Our solution to this problem was to make use of a custom service host factory. I’ve touched on the custom service host factory subject &lt;a href="http://www.darkside.co.za/archive/2008/02/21/custom-servicehostfactory-for-wcf-and-iis.aspx" target="_blank"&gt;here&lt;/a&gt; before, and this solution is just another use of it.&lt;/p&gt;  &lt;div class="Code"&gt;   &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;CustomServiceHostFactory&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;ServiceHostFactory&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;readonly&lt;/span&gt; &lt;span style="color: blue"&gt;object&lt;/span&gt; m_InitActiveRecordLock = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: blue"&gt;object&lt;/span&gt;();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; System.ServiceModel.&lt;span style="color: #2b91af"&gt;ServiceHostBase&lt;/span&gt; CreateServiceHost(&lt;span style="color: blue"&gt;string&lt;/span&gt; constructorString, &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: green"&gt;//Initialise ActiveRecord...&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;if&lt;/span&gt; (!&lt;span style="color: #2b91af"&gt;ActiveRecordStarter&lt;/span&gt;.IsInitialized)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            &lt;span style="color: blue"&gt;lock&lt;/span&gt; (m_InitActiveRecordLock)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                &lt;span style="color: blue"&gt;if&lt;/span&gt; (!&lt;span style="color: #2b91af"&gt;ActiveRecordStarter&lt;/span&gt;.IsInitialized)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                    &lt;span style="color: #2b91af"&gt;ActiveRecordStarter&lt;/span&gt;.Initialize(&lt;span style="color: #2b91af"&gt;Assembly&lt;/span&gt;.Load(&lt;span style="color: #a31515"&gt;"Darkside.Domain"&lt;/span&gt;), &lt;span style="color: #2b91af"&gt;ActiveRecordSectionHandler&lt;/span&gt;.Instance);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;                }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;            }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: green"&gt;//Hand off the real host creation to the base class..&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;        &lt;span style="color: blue"&gt;return&lt;/span&gt; (&lt;span style="color: blue"&gt;base&lt;/span&gt;.CreateServiceHost(constructorString, baseAddresses));&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You then need to add the Factory attribute into your .SVC file&lt;/p&gt;

&lt;div class="Code"&gt;
  &lt;pre style="margin: 0px"&gt;&lt;span style="background: yellow"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue"&gt;@&lt;/span&gt; &lt;span style="color: maroon"&gt;ServiceHost&lt;/span&gt; &lt;span style="color: red"&gt;Language&lt;/span&gt;&lt;span style="color: blue"&gt;="C#"&lt;/span&gt; &lt;span style="color: red"&gt;Debug&lt;/span&gt;&lt;span style="color: blue"&gt;="false"&lt;/span&gt; &lt;span style="color: red"&gt;Service&lt;/span&gt;&lt;span style="color: blue"&gt;="Darkside.Services.CRUDService, Darkside.Services"&lt;/span&gt; &lt;span style="color: red"&gt;Factory&lt;/span&gt;&lt;span style="color: blue"&gt;="Darkside.WAS.CustomServiceHostFactory"&lt;/span&gt; &lt;span style="background: yellow"&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now, if a new service host is created in your app, AR will be initialised first, if needed.&lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/115.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2010/07/16/initialise-castle-activerecord-was-wcf.aspx</guid>
            <pubDate>Fri, 16 Jul 2010 09:25:53 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2010/07/16/initialise-castle-activerecord-was-wcf.aspx#feedback</comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/115.aspx</wfw:commentRss>
        </item>
        <item>
            <title>A little gem. Or a WTF. You decide&amp;hellip;</title>
            <link>http://www.darkside.co.za/archive/2010/07/15/114.aspx</link>
            <description>&lt;p&gt;Here’s a winner snippet of code I found:&lt;/p&gt;  &lt;div class="Code"&gt;   &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;enum&lt;/span&gt; &lt;span style="color: #2b91af"&gt;BooleanComparer&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    True,&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;    False&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;I laughed. I cried. I came to the conclusion that maybe booleans are just not for everyone.&lt;/p&gt;&lt;img src="http://www.darkside.co.za/aggbug/114.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Schreiber</dc:creator>
            <guid>http://www.darkside.co.za/archive/2010/07/15/114.aspx</guid>
            <pubDate>Thu, 15 Jul 2010 06:12:48 GMT</pubDate>
            <comments>http://www.darkside.co.za/archive/2010/07/15/114.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://www.darkside.co.za/comments/commentRss/114.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>

