<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Living in the Tech Avalanche Generation</title>
	<atom:link href="http://www.simonsegal.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonsegal.net/blog</link>
	<description>A practitioner's introspective on technology</description>
	<pubDate>Mon, 21 Jun 2010 00:16:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
	<creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.5/au/</creativeCommons:license>		<item>
		<title>MongoDB Training in Australia with 10Gen &#8211; be counted!</title>
		<link>http://www.simonsegal.net/blog/2010/05/19/mongodb-training-in-australia-with-10gen-be-counted/</link>
		<comments>http://www.simonsegal.net/blog/2010/05/19/mongodb-training-in-australia-with-10gen-be-counted/#comments</comments>
		<pubDate>Tue, 18 May 2010 22:09:08 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/05/19/mongodb-training-in-australia-with-10gen-be-counted/</guid>
		<description><![CDATA[I’m super excited, 10Gen are currently taking a survey for registrations of interest for MongoDB training run by them in Australia. So, I would implore anyone with a eye on the NOSQL or MongoDB space to get over quickly to survey monkey to fill in the Survey and show your Mongo love! 
 It’s been [...]<p><a href="http://www.simonsegal.net/blog/2010/05/19/mongodb-training-in-australia-with-10gen-be-counted/">MongoDB Training in Australia with 10Gen &ndash; be counted!</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I’m super excited, <a href="http://www.10gen.com/" target="_blank">10Gen</a> are currently taking a survey for registrations of interest for <a href="http://www.mongodb.org/" target="_blank">MongoDB</a> training run by them in Australia. So, I would implore anyone with a eye on the NOSQL or MongoDB space to get over quickly to survey monkey to <a href="http://www.surveymonkey.com/s/SYGGJ3W" target="_blank">fill in the Survey</a> and show your Mongo love! </p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/logomongodbonwhite.png"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 5px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="logo-mongodb-onwhite" border="0" alt="logo-mongodb-onwhite" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/logomongodbonwhite-thumb.png" width="110" height="52" /></a> It’s been palpable the level of interest and noise being made by the .NET community around MongoDB, however MongoDB has no special language affiliation and the Survey seeks to know your language preference&#160; (with regards to the training), so if your simply interested in imbibing on the best MongoDB training around, then fill in the Survey and spread the word.</p>
<p>Here is <a href="http://www.surveymonkey.com/s/SYGGJ3W" target="_blank">the link to register your interest</a>.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=MongoDB%20Training%20in%20Australia%20with%2010Gen%20%26ndash%3B%20be%20counted%21&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F05%2F19%2Fmongodb-training-in-australia-with-10gen-be-counted%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="MongoDB Training in Australia with 10Gen &ndash; be counted!";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/05/19/mongodb-training-in-australia-with-10gen-be-counted/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/05/19/mongodb-training-in-australia-with-10gen-be-counted/">MongoDB Training in Australia with 10Gen &ndash; be counted!</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/05/19/mongodb-training-in-australia-with-10gen-be-counted/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IronPython Tools for Visual Studio with Expression Blend</title>
		<link>http://www.simonsegal.net/blog/2010/05/09/ironpython-tools-for-visual-studio-with-expression-blend/</link>
		<comments>http://www.simonsegal.net/blog/2010/05/09/ironpython-tools-for-visual-studio-with-expression-blend/#comments</comments>
		<pubDate>Sun, 09 May 2010 06:36:35 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Expression Blend]]></category>

		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<category><![CDATA[WPF]]></category>

		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/05/09/ironpython-tools-for-visual-studio-with-expression-blend/</guid>
		<description><![CDATA[Just as I was about to embark on&#160; a new project (codenamed PONGO), the IronPython team announced a CTP 2.0 drop of the IronPython tools for Visual Studio 2010 which is exciting on a number of different levels. 
If IronRuby and IronPython eventually make it all the way to Visual Studio integration in the full [...]<p><a href="http://www.simonsegal.net/blog/2010/05/09/ironpython-tools-for-visual-studio-with-expression-blend/">IronPython Tools for Visual Studio with Expression Blend</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Just as I was about to embark on&#160; a new project (codenamed PONGO), the IronPython team announced a CTP 2.0 drop of the <a href="http://ironpython.net/tools/">IronPython tools for Visual Studio 2010</a> which is exciting on a number of different levels. </p>
<p>If IronRuby and IronPython eventually make it all the way to Visual Studio integration in the full sense (that is packaged as part of Visual Studio itself) that would be a mark of first class citizenry.</p>
<h2><u>What about Expression Blend?</u></h2>
<p>Personally I work in both Blend and Visual Studio and even though the Visual Studio designer is somewhat improved and it’s intellisense is far superior than that of Expression Blend, it still does not provide me with the same fidelity or fluency in the design experience as I get from Blend. This leaves me with a problem when it comes to building applications where IronPython is the choice language. </p>
<p>It would have been unrealistic (at this stage) to expect Blend to open IronPython projects created in Visual Studio and sure enough that is the not case. What might be useful is Blend having a “<strong><em>design XAML only mode</em></strong>”, enabling it to open <strong>XAML</strong> files individually, taking advantage of the design experience it has to offer. Still not ready to give up on using Blend with XAML files that were part of a Visual Studio IronPython project, I set out to find a way.</p>
<h2><u>Symbolic Links</u></h2>
<p>The first thing I tried out was to see if Symbolic and Hard linked files would make the difference? First up I tried a symbolic link using the MKLINK utility:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">MKLINK [[/D] | [/H] | [/J]] Link Target</pre>
<p></div>
</p>
<p>Before doing this I created two projects, the first one an <a href="http://ironpython.net/tools/">IronPython Tools</a> project generated in Visual Studio and the second one a C# project created in Blend.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pongoprojects.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PongoProjects" border="0" alt="PongoProjects" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pongoprojects-thumb.png" width="475" height="297" /></a></p>
<p>It should be obvious from the naming which project is which. In the blend project I removed the default XAML file generated by Blend.</p>
<p>Next came the file linking, I used only the <strong><em>Link</em></strong> and <strong><em>Target</em></strong> command line options, creating a symbolic link using the same name as the .XAML file in my IronPython project.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">MKLINK pongo.xaml d:\temp\PongoBlend\pongo.xaml</pre>
<p></div>
<p>Having successfully created the soft linked symbolic file I tried to add it to the Blend project only to find that it would not open – which, to blunt I wasn’t expecting to work. I was a little more hopeful however when it came to the Hard Linked file which I setup as follows:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">MKLINK \H pongo.xaml d:\temp\PongoBlend\pongo.xaml</pre>
<p></div>
<p>This did in fact open correctly in Blend and worked for a brief moment, when I changed something in Blend – Visual Studio would prompt me that the file had been changed outside the editor, unfortunately my celebrations were short lived when I found that the files were not updating in both locations when one or the other was subject to an edit. After some investigation and testing it appears that once opening the file in both the IDE’s the links would somehow eventually become broken and so the symbolic linking idea was now officially a lost prospect.</p>
<h2><u>Duelling Projects</u></h2>
<p>Finally I decided to synchronize two separate .XAML files in each of the two different projects, so the challenge was to find the most unobtrusive way of working in both IDE’s and easily syncing the the .XAML files after edits had been made. Given that one of the IDE’s was running a dynamic language with a REPL built in, I thought it shouldn’t prove too difficult. </p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pongvsnet-interactive.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="pongvsnet_interactive" border="0" alt="pongvsnet_interactive" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pongvsnet-interactive-thumb.png" width="475" height="317" /></a> </p>
<p>What I did was to add two <strong><em>.py</em></strong> source files into the project, each one with some code that would sync in one direction, either from Blend to Visual Studio and vice versa. Sure its&#160; far from a perfect solution but it just might be a price I’m willing to pay in the short term to get the benefit of using Blend. In the long term I really do hope that as the dynamic languages gain support in Visual Studio we also get some integrated ways to work in both IDE’s.</p>
<h2></h2>
</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pongvsnet-with-xaml-ui.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="pongvsnet_with_xaml_ui" border="0" alt="pongvsnet_with_xaml_ui" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pongvsnet-with-xaml-ui-thumb.png" width="483" height="378" /></a></p>
<p>Here’s the very same Pongo.xaml file (or copy of it to be precise) in Expression Blend, but before you get too excited, the “send to interactive console” context menu option seems to suffer some kind of inconsistent behaviour (on my machine any way), causing the File copy operation in my .py files to work on only some occasions. </p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pong-in-blend.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="pong_in_blend" border="0" alt="pong_in_blend" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/05/pong-in-blend-thumb.png" width="485" height="366" /></a> </p>
<p>Undeterred I decided to fall back to an even more disintegrated experience and opt for running the synchronizing .py files in IPY.exe itself. This is easily achieved by associating <strong><em>.py</em></strong> files to the IPY.exe in Visual Studio using the context menu’s <strong><em>“open with”</em></strong> option, which is a something existing Visual Studio users will be very familiar with.</p>
<p>Like I said its far from a perfect solution and to be frank it’s somewhat annoying however my frustration is another thing altogether if I’m faced with doing all my layout and design in Visual Studio – so I will live with it for the moment. Hopefully the IronPython team and or the Expression Blend Team can find a solution that flows changes through more seamlessly in the short term and the perhaps in the long term allow us to open IronPython and IronRuby projects in Blend.</p>
<p>By the way if your wondering about the codename of the project that drove this adventure (PONGO) – the answer is yes if you guessed that it’s something that revolves around IronPython and MongoDB and I will be blogging about that more in the coming weeks.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=IronPython%20Tools%20for%20Visual%20Studio%20with%20Expression%20Blend&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F05%2F09%2Fironpython-tools-for-visual-studio-with-expression-blend%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="IronPython Tools for Visual Studio with Expression Blend";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/05/09/ironpython-tools-for-visual-studio-with-expression-blend/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/05/09/ironpython-tools-for-visual-studio-with-expression-blend/">IronPython Tools for Visual Studio with Expression Blend</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/05/09/ironpython-tools-for-visual-studio-with-expression-blend/feed/</wfw:commentRss>
		</item>
		<item>
		<title>NFetchSpec Code &#8211; Entity Framework Repository, Fetching Strategies, Specifications, Code Only, Mapping, POCO and Making Roles Explicit.</title>
		<link>http://www.simonsegal.net/blog/2010/03/18/nfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit/</link>
		<comments>http://www.simonsegal.net/blog/2010/03/18/nfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 10:56:02 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DDD]]></category>

		<category><![CDATA[Design Patterns]]></category>

		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/03/18/nfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit/</guid>
		<description><![CDATA[I have made the code from the NFetchSpec spiking / proof of concept available here. Be aware that it requires .NET Framework 4.0, Entity Framework 4.0 and the Feature CTP&#160; versions 2 or 3. I won’t be revising this code until the official release of version 4.0 and it will likely get some reworking. In [...]<p><a href="http://www.simonsegal.net/blog/2010/03/18/nfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit/">NFetchSpec Code &ndash; Entity Framework Repository, Fetching Strategies, Specifications, Code Only, Mapping, POCO and Making Roles Explicit.</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I have made the code from the NFetchSpec spiking / proof of concept available <a href="http://www.simonsegal.net/blog/CodeDownloads/NFetchSpec.rar">here</a>. Be aware that it requires .NET Framework 4.0, Entity Framework 4.0 and the Feature CTP&#160; versions 2 or 3. I won’t be revising this code until the official release of version 4.0 and it will likely get some reworking. In the meantime if you want to understand the ideas in parts <a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/">1</a>, <a href="http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/">2</a>, <a href="http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/">3</a>, and <a href="http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/">4</a> of <a href="http://www.simonsegal.net/blog/index.php?s=Helping+the+Entity+Framework+Play&amp;sbutt=Go">Helping the Entity Framework Play it’s &lt;ROLE&gt;</a> the you can feel free to pull the code apart and do with it what you will. Until then.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=NFetchSpec%20Code%20%26ndash%3B%20Entity%20Framework%20Repository%2C%20Fetching%20Strategies%2C%20Specifications%2C%20Code%20Only%2C%20Mapping%2C%20POCO%20and%20Making%20Roles%20Explicit.&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F03%2F18%2Fnfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="NFetchSpec Code &ndash; Entity Framework Repository, Fetching Strategies, Specifications, Code Only, Mapping, POCO and Making Roles Explicit.";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/03/18/nfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/03/18/nfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit/">NFetchSpec Code &ndash; Entity Framework Repository, Fetching Strategies, Specifications, Code Only, Mapping, POCO and Making Roles Explicit.</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/03/18/nfetchspec-code-entity-framework-repository-fetching-strategies-specifications-code-only-mapping-poco-and-making-roles-explicit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Helping Entity Framework v4.0 play it&#8217;s &#60;ROLE&#62; &#8211; Part 4.0</title>
		<link>http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/</link>
		<comments>http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 01:11:30 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DDD]]></category>

		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[NServiceBus]]></category>

		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/</guid>
		<description><![CDATA[Before diving in you might like to read parts 1, 2 and 3 if you have come to this post out of sync. Also if you are not familiar with some of the newer aspects of the Code Only CTP for Entity Framework it might be worth looking here on the ADO.Net Team blog.
The Service [...]<p><a href="http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/">Helping Entity Framework v4.0 play it&rsquo;s &lt;ROLE&gt; &ndash; Part 4.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Before diving in you might like to read parts <a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/">1</a>, <a href="http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/">2</a> and <a href="http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/">3</a> if you have come to this post out of sync. Also if you are not familiar with some of the newer aspects of the Code Only CTP for Entity Framework it might be worth looking here on the <a href="http://blogs.msdn.com/adonet/">ADO.Net Team blog</a>.</p>
<h2><span style="text-decoration: underline;">The Service Layer</span></h2>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/03/nfetchspec-servicelayer-2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="nfetchspec_serviceLayer_2" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/03/nfetchspec-servicelayer-2-thumb.png" border="0" alt="nfetchspec_serviceLayer_2" width="473" height="314" /></a></p>
<p>I want to point out that this approach in development is not restricted to a technology or architecture per`se and in discussing how it fits with a ‘Service Layer’ is equally valid for a Layered Request / Response style Architecture and asynchronous messaging systems with very well defined business components.</p>
<p>Let’s start with a run of the mill WCF approach – I have purposely elided the interface contract for the sake of brevity.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">[OperationContract(IsOneWay=<span style="color: #0000ff;">true</span>)]
[OperationBehaviour(TranactionScopeRequired=<span style="color: #0000ff;">true</span>,
                    TransactionScopeAutoComplete=<span style="color: #0000ff;">false</span>)]
<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> DiscountRunOutProducts()
{
    IList&lt;IRunOutDiscountForProducts&gt; products = <span style="color: #0000ff;">null</span>;

    var compParams = <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt;();
    compParams.Add(_conParamName, _connectionStringOnly);

    var repo = FetchSpec
                    .Configure
                    .With(<span style="color: #0000ff;">new</span> IoC())
                    .AndBuildSession&lt;IRunOutDiscountForProducts&gt;(compParams)
                    .ForRepository();

    <span style="color: #0000ff;">using</span> (var scope = <span style="color: #0000ff;">new</span> TransactionScope(TransactionScopeOption.Required,
        <span style="color: #0000ff;">new</span> TransactionOptions()
        {
            IsolationLevel =
                SessionBuilder&lt;IRunOutDiscountForProducts&gt;.ScopeIsolation()
        }))
    {
        products = repo.Get&lt;IRunOutDiscountForProducts&gt;();

        <span style="color: #0000ff;">foreach</span> (var product <span style="color: #0000ff;">in</span> products)
        {
            product.DiscountProductForRunOut();
        }

        scope.Complete();
    }
}</pre>
</div>
<p>Every expression of intent here is explicit, from the name of the service operation, all the way to the application of the ROLE to the ORM. From an ongoing maintenance perspective, when any of the given actors need to be varied through the life cycle of the software, this can be done independently. For example, we don’t have to revisit our service layers code when we profile the system and find that the fetching strategy should be eager fetching for a given scenario, instead we can build a new version of the existing Fetching Strategy and drop it in. This kind of flexibility ripples through the system, with the same said for Specifications, Message Handlers, so on and so forth. If of course you wanted to change the code to accept a Specification ‘in line’ rather than have it deployed and dynamically resolved, then you could probably have just implemented an overloaded version of the Service operation to begin with and pass in the parameters required to build those pieces at runtime. The example is a one way operation but you could easily be returning values and accepting parameters (think DTO’s) in a request / response scenario. Bear in mind these DTO’s are not being mapped and subsequently attached, they are either parameters for the ORM or return property buckets for binding or mapping to a presentation model.</p>
<p>For a point of difference, let’s take a look at how this might work if our Service Layer was implemented on top of the popular Open Source Framework <a href="http://www.nservicebus.com/">NServiceBus</a>.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> DiscountRunOutProductsMessage: IMessage
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> DiscountedRegion{ get; set; }
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">decimal</span> UnitPrice{ get; set; }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> DiscountRunOutProducts :
             IMessageHandler&lt;DiscountRunOutProductsMessage&gt;
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> Handle(DiscountRunOutProductsMessage message)
    {
        IList&lt;IRunOutDiscountForProducts&gt; products = <span style="color: #0000ff;">null</span>;

        var compParams = <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt;();
        compParams.Add(_conParamName, _connectionStringOnly);

        var repo = FetchSpec.Configure
                            .With(<span style="color: #0000ff;">new</span> IoC())
                            .AndBuildSession&lt;IRunOutDiscountForProducts&gt;
                                (compParams)
                            .ForRepository();

        <span style="color: #0000ff;">using</span> (var scope = <span style="color: #0000ff;">new</span> TransactionScope(TransactionScopeOption.Required,
            <span style="color: #0000ff;">new</span> TransactionOptions()
            {
                IsolationLevel =
                    SessionBuilder&lt;IRunOutDiscountForProducts&gt;.ScopeIsolation()
            }))
        {
            var spec = <span style="color: #0000ff;">new</span> Specification&lt;IRunOutDiscountForProducts&gt;
                            (p =&gt; p.UnitPrice &lt; message.UnitPrice &amp;&amp;
                             p.Supplier.Region = message.DiscountedRegion);

            products = repo.Get&lt;IRunOutDiscountForProducts&gt;(spec);

            <span style="color: #0000ff;">foreach</span> (var product <span style="color: #0000ff;">in</span> products)
            {
                product.DiscountProductForRunOut();
            }

            scope.Complete();
        }
    }
}</pre>
</div>
<p>Something worth pointing out in our NServiceBus example is that it too is quite explicit. The message handler, handles messages expressly for the purpose of discounting products to be ‘run out’, exemplifying how the pattern is becoming more entrenched in our style of working. Once again, if we don’t like anything about the way the handler is doing it’s work, we can throw it away in preference for a new implementation.</p>
<h2><span style="text-decoration: underline;">Not to be left out</span></h2>
<p><a href="http://blogger.forgottenskies.com/">Steve</a> left a <a href="http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/#comments">comment</a> and asked me not to forgo examples that dealt with inserting and updating data, Steve also wanted to know about how I go about dealing with the Unit of Work and the ‘per session’ vs. &#8216;conversation’ and the differences that spring up and also when working with WCF and dealing with optimistic concurrency. Fortunately this part in the series takes aim squarely at how to go about using Entity Framework in concert with Roles from the Service Layer and we tackle those questions by necessity.</p>
<h3><span style="text-decoration: underline;">Listing 1.0 – Inserts</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> add_a_product()
{
    var compParams = <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt;();
    compParams.Add(_conParamName, _connectionStringOnly);

    var repo = FetchSpec.Configure
                        .With(<span style="color: #0000ff;">new</span> StubIoc() {
                            ScannedAssemblyPath = _scannedAssemblyPath })
                        .AndBuildSession&lt;ICustomerToAddOrder&gt;(compParams)
                        .ForRepository();

    var spec =
        <span style="color: #0000ff;">new</span> Specification&lt;ICustomerToAddOrder&gt;(c =&gt; c.CustomerID == <span style="color: #006080;">&#8220;ALFKI&#8221;</span>);
    var config = <span style="color: #0000ff;">new</span> IQueryConfigurable[] { spec };

    <span style="color: #0000ff;">using</span> (var scope = <span style="color: #0000ff;">new</span> TransactionScope(TransactionScopeOption.Required,
        <span style="color: #0000ff;">new</span> TransactionOptions()
        {
                IsolationLevel =
                    SessionBuilder&lt;ICustomerToAddOrder&gt;.ScopeIsolation()
        }))
    {
        dynamic customer = repo.Get&lt;ICustomerToAddOrder&gt;(config).First();

        var order = repo.IocContainer
                        .ConvertFromRoleToImpl&lt;IOrderToAddToCustomer&gt;();
        order.CustomerID = customer.CustomerID;
        order.Customer = customer;

        customer.AddOrder(order);

        repo.Save();

        scope.Complete();
    }
}</pre>
</div>
<h2><span style="text-decoration: underline;">Not entirely in the spirit of things</span></h2>
<p>Notice the use of the <span style="color: #0080ff;"><strong><em>dynamic</em></strong></span> keyword above (suggested by <a href="http://www.markharris.net.au/">Mark</a>) Let me explain. Due the Entity Frameworks hard and fast rule of only allowing EntityConfiguration&lt;T&gt; to specify a concrete class as it’s generic argument, the flow through effects have rippled out, with the customer variable and the order variable. The problem is that the IoC container can’t know ahead of time what the implementation type for the interface might be and order.Customer property is forced to use a concrete type (not interface) to satisfy the Entity Framework for mapping purposes enforced by EntityConfiguration&lt;T&gt;. After speaking to <a href="http://blogs.rev-net.com/ddewinter/">David DeWinter</a> (a Tester on the EF Team who responded to a tweet I made), he suggested that it was likely implemented this way to satisfy ObjectSet&lt;T&gt; which also constrains to a concrete implementation (makes sense).</p>
<p>Ultimately the <strong><em><span style="color: #0080ff;">dynamic</span></em></strong> keyword will get us over the line with respect to this one final hurdle, however my gut says that this work around isn’t entirely in the spirit of NFetchSpec and smacks a little of my old enemy the VARIANT, but I’m prepared to make this one allowance to get me working in a way that suits my needs. I can still read the code somewhat clearly because even when I’m using <em><strong><span style="color: #0080ff;">dynamic</span></strong></em> for assignment, I can reason about the type based on the interface specified to the repository and the IoC container. I would love to think that this is something that the Entity Framework team might address but I guess I will just have to wait and see.</p>
<h2><span style="text-decoration: underline;">Under the covers</span></h2>
<p>What code did I need to write to support this ‘adding a product to a customer’ scenario? First up I needed the role itself, then the entities, the mapping classes, the mapping role class and I also needed to write an implementation for IProvideIsolationLevelFor. The Specification I chose to write inline because the parameter value would be provided at run time. Here is the all of it:</p>
<h3><span style="text-decoration: underline;">The Roles</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> ICustomerToAddOrder
{
    <span style="color: #0000ff;">void</span> AddOrder(IOrderToAddToCustomer order);
    <span style="color: #0000ff;">string</span> CustomerID { get; set; }
    ICollection&lt;OrderToAddToCustomer&gt; Orders { get; set; }
}</pre>
</div>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IOrderToAddToCustomer
{
    <span style="color: #0000ff;">string</span> CustomerID { get; set; }
    CustomerToAddOrder Customer { get; set; }
    <span style="color: #0000ff;">int</span> OrderID { get; set; }
}</pre>
</div>
<h3><span style="text-decoration: underline;">The Entities</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> CustomerToAddOrder : IEntity, ICustomerToAddOrder
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> CustomerID { get; set; }
    <span style="color: #0000ff;">public</span> ICollection&lt;OrderToAddToCustomer&gt; Orders { get; set; }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> AddOrder(IOrderToAddToCustomer order)
    {
        <span style="color: #0000ff;">if</span> (Orders == <span style="color: #0000ff;">null</span>)
            Orders = <span style="color: #0000ff;">new</span> List&lt;OrderToAddToCustomer&gt;();

        Orders.Add(order <span style="color: #0000ff;">as</span> OrderToAddToCustomer);
    }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> OrderToAddToCustomer : IEntity, IOrderToAddToCustomer
{
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> CustomerID
    {
        get;
        set;
    }

    <span style="color: #0000ff;">public</span> CustomerToAddOrder Customer
    {
        get;
        set;
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> OrderID
    {
        get;
        set;
    }
}</pre>
</div>
<h3><span style="text-decoration: underline;">The Mapping Classes</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> CustomerToAddOrderMapping : Mapping&lt;CustomerToAddOrder&gt;
{
    <span style="color: #0000ff;">public</span> CustomerToAddOrderMapping(<span style="color: #0000ff;">string</span> objectSetName)
        : <span style="color: #0000ff;">base</span>(objectSetName)
    {
        Property(c =&gt; c.CustomerID).HasMaxLength(5).IsRequired();
        HasKey(c =&gt; c.CustomerID);
        Relationship(c =&gt; c.Orders).IsOptional();
    }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> OrderToAddToCustomerMapping : Mapping&lt;OrderToAddToCustomer&gt;
{
    <span style="color: #0000ff;">public</span> OrderToAddToCustomerMapping(<span style="color: #0000ff;">string</span> objectSetName)
        : <span style="color: #0000ff;">base</span>(objectSetName)
    {
        Property(o =&gt; o.OrderID).IsIdentity();
        Property(o =&gt; o.CustomerID).HasMaxLength(5).IsRequired();
        HasKey(o =&gt; o.OrderID);
        Relationship(o =&gt; o.Customer)
            .FromProperty(c =&gt; c.Orders)
            .HasConstraint((o, c) =&gt; o.CustomerID == c.CustomerID);
    }
}</pre>
</div>
<h3><span style="text-decoration: underline;">The Mapping Role</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> CustomerToAddOrderMappingRole :
        IMappingRole&lt;ICustomerToAddOrder&gt;
{
    <span style="color: #0000ff;">private</span> IMapping[] _mappings;

    <span style="color: #0000ff;">public</span> CustomerToAddOrderMappingRole()
    {
        _mappings = <span style="color: #0000ff;">new</span> IMapping[]
        {
            <span style="color: #0000ff;">new</span> CustomerToAddOrderMapping(<span style="color: #006080;">&#8220;Customers&#8221;</span>),
            <span style="color: #0000ff;">new</span> OrderToAddToCustomerMapping(<span style="color: #006080;">&#8220;Orders&#8221;</span>)
        };
    }

    <span style="color: #0000ff;">public</span> IMapping[] Mappings
    {
        get { <span style="color: #0000ff;">return</span> _mappings; }
    }
}</pre>
</div>
<h3><span style="text-decoration: underline;">The Transaction Isolation Class</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> AddOrderToCustomerIsolation :
        IProvideIsolationLevelFor&lt;ICustomerToAddOrder&gt;
{
    <span style="color: #0000ff;">public</span> IsolationLevel GetScopeIsolationForRole
    {
        get { <span style="color: #0000ff;">return</span> IsolationLevel.ReadCommitted; }
    }
}</pre>
</div>
<h2><span style="text-decoration: underline;">Piggy in the middle</span></h2>
<p>The issue of managing a short or extended session with an ObjectContext is something that I think a lot of people struggle with. Personally I have never had such an issue because they way I have always worked always involved fetching the most current version of the data I required to have my domain model work against it. This way of working has stayed with me through time immemorial, even in my dark old days of using an anaemic domain model.  To be clear I do not pass DTO’s around and reattach them to the ObjectContext, rather refreshing the data and letting the domain model’s business logic take care of the rest.</p>
<h2><span style="text-decoration: underline;">In Conclusion</span></h2>
<p>My initial planning for the series was that would be take up four posts and therefore it is expected that this may be the last in the series. However, given that Entity Framework 4.0 is still not at RTM and Code Only is still in CTP then it’s possible I may revisit it with a further post sometime in the future.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Helping%20Entity%20Framework%20v4.0%20play%20it%26rsquo%3Bs%20%3CROLE%3E%20%26ndash%3B%20Part%204.0&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F03%2F15%2Fhelping-entity-framework-v40-play-its-role-part-40%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Helping Entity Framework v4.0 play it&rsquo;s <ROLE> &ndash; Part 4.0";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/">Helping Entity Framework v4.0 play it&rsquo;s &lt;ROLE&gt; &ndash; Part 4.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Are we not men - we are Devo?</title>
		<link>http://www.simonsegal.net/blog/2010/03/12/are-we-not-men-we-are-devo/</link>
		<comments>http://www.simonsegal.net/blog/2010/03/12/are-we-not-men-we-are-devo/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 11:03:05 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Career]]></category>

		<category><![CDATA[developers]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/03/12/are-we-not-men-we-are-devo/</guid>
		<description><![CDATA[ 
Does this look like you? Are you surrounded by like minded individuals, sharing a community experience at work with your fellow geeks? Perhaps you have even gone further than that and made a lasting friend or two out of your fellow developers. That certainly describes&#160; the kind of environment that I flourish in and [...]<p><a href="http://www.simonsegal.net/blog/2010/03/12/are-we-not-men-we-are-devo/">Are we not men - we are Devo?</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/03/image2.png"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/03/image-thumb2.png" width="151" height="167" /></a> </p>
<p>Does this look like you? Are you surrounded by like minded individuals, sharing a community experience at work with your fellow geeks? Perhaps you have even gone further than that and made a lasting friend or two out of your fellow developers. That certainly describes&#160; the kind of environment that I flourish in and in my more senior years, have worked hard to foster. It’s my experience that software developed in this environment is more cohesive and easier to maintain over the long haul. With he right personality types, social activity at work for geeks&#160; often means talking shop and this leads to a win – win situation for everyone. More ideas begat better ideas, common work patterns begin to evolve; other than that it’s just plain more enjoyable.</p>
<p>However I have struck the odd workplace that is the antithesis of what I have just described. Personality bereft work silos, with dead silence abounding throughout the organisation, lack of willingness to work together, fostering a cycle of suspicion and loss of preparedness to work as a team. I have seen enough of this type of work place to know that I can never work in one again.</p>
<p>Of course it’s possible that I have just described your workplace and perhaps even worse than that, it’s the way it is because you designed it to be that way? What kind of work environment do you have? Do the developers at your office communicate with one another vibrantly, rich in tone and timbre, taking coffee breaks together, occasionally going out for lunch and generally taking any office bound social opportunity to debate and discuss geeky things? Do you have a mate at work? </p>
<p>I would really be interested to hear the arguments (if there are any) that make a case for this almost <a href="http://en.wikipedia.org/wiki/Bertolt_Brecht">Brechtian</a> bleakness and minimalism in surroundings.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Are%20we%20not%20men%20-%20we%20are%20Devo%3F&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F03%2F12%2Fare-we-not-men-we-are-devo%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Are we not men - we are Devo?";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/03/12/are-we-not-men-we-are-devo/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/03/12/are-we-not-men-we-are-devo/">Are we not men - we are Devo?</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/03/12/are-we-not-men-we-are-devo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ADSD Course with Udi Dahan in Sydney Australia for November 2010</title>
		<link>http://www.simonsegal.net/blog/2010/03/04/adsd-course-with-udi-dahan-in-sydney-australia-for-november-2010/</link>
		<comments>http://www.simonsegal.net/blog/2010/03/04/adsd-course-with-udi-dahan-in-sydney-australia-for-november-2010/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 06:50:04 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DDD]]></category>

		<category><![CDATA[Distributed]]></category>

		<category><![CDATA[NServiceBus]]></category>

		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/03/04/adsd-course-with-udi-dahan-in-sydney-australia-for-november-2010/</guid>
		<description><![CDATA[ Hot on the heels of Udi’s visit to Melbourne this year (in January), comes another chance to make good if you missed out. Plans are underway for Udi to visit us yet again, this time in Sydney. If your interested check out Udi’s post and register your interest using the link for the proposed [...]<p><a href="http://www.simonsegal.net/blog/2010/03/04/adsd-course-with-udi-dahan-in-sydney-australia-for-november-2010/">ADSD Course with Udi Dahan in Sydney Australia for November 2010</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/03/image1.png"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 5px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/03/image-thumb1.png" width="157" height="75" /></a> Hot on the heels of Udi’s <a href="http://www.simonsegal.net/blog/guests-on-demand/">visit to Melbourne</a> this year (in January), comes another chance to make good if you missed out. Plans are underway for Udi to visit us yet again, this time in Sydney. If your interested check out Udi’s <a href="http://www.udidahan.com/2010/03/01/nservicebus-2-0-rtm/">post</a> and register your interest using the link for the proposed Sydney event. If you want to know more about the course you can see the course outline <a href="http://www.udidahan.com/training/">here</a> and read <a href="http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/">my review</a> which contains links to some further reviews from other attendees in Melbourne earlier this year.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=ADSD%20Course%20with%20Udi%20Dahan%20in%20Sydney%20Australia%20for%20November%202010&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F03%2F04%2Fadsd-course-with-udi-dahan-in-sydney-australia-for-november-2010%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="ADSD Course with Udi Dahan in Sydney Australia for November 2010";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/03/04/adsd-course-with-udi-dahan-in-sydney-australia-for-november-2010/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/03/04/adsd-course-with-udi-dahan-in-sydney-australia-for-november-2010/">ADSD Course with Udi Dahan in Sydney Australia for November 2010</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/03/04/adsd-course-with-udi-dahan-in-sydney-australia-for-november-2010/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Helping Entity Framework v4.0 play it&#8217;s &#60;ROLE&#62; &#8211; Part 3.0</title>
		<link>http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/</link>
		<comments>http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 11:33:23 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DDD]]></category>

		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[Patterns &amp; Practices]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/</guid>
		<description><![CDATA[In part 1.0 we laid the foundation and part 2.0 unravelled some of the internal details of how NFetchSpec (the libraries that are subject of this discussion) goes about enlisting the benefits that can be derived by using explicit roles in your system by collapsing a swathe of Entity Framework functionality into a somewhat compact [...]<p><a href="http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/">Helping Entity Framework v4.0 play it&rsquo;s &lt;ROLE&gt; &ndash; Part 3.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/">part 1.0</a> we laid the foundation and <a href="http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/">part 2.0</a> unravelled some of the internal details of how NFetchSpec (the libraries that are subject of this discussion) goes about enlisting the benefits that can be derived by using explicit roles in your system by collapsing a swathe of Entity Framework functionality into a somewhat compact approach to dealing with a Domain Model. First a quick recap of the underpinnings.</p>
<h3><span style="text-decoration: underline">Figure 1.0</span></h3>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/ef-roles-part3-nfetch-in-action-usage-quadrant.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ef_roles_part3_nfetch_in_action_usage_quadrant" border="0" alt="ef_roles_part3_nfetch_in_action_usage_quadrant" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/ef-roles-part3-nfetch-in-action-usage-quadrant-thumb.png" width="490" height="413" /></a></p>
<h4><span style="text-decoration: underline">Code from Figure 1.0</span></h4>
<p><span style="text-decoration: underline"></span></p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> resolves_everything_from_container()
{
    IList&lt;IRunOutDiscountForProducts&gt; products = <span style="color: #0000ff">null</span>;

    var compParams = <span style="color: #0000ff">new</span> Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">string</span>&gt;();
    compParams.Add(_conParamName, _connectionStringOnly);

    var repo = FetchSpec.Configure
                            .With(<span style="color: #0000ff">new</span> IoC())
                            .AndBuildSession&lt;IRunOutDiscountForProducts&gt;
                                (compParams)
                            .ForRepository();

    <span style="color: #0000ff">using</span> (var scope = <span style="color: #0000ff">new</span> TransactionScope(TransactionScopeOption.Required,
        <span style="color: #0000ff">new</span> TransactionOptions()
        {
            IsolationLevel =
                SessionBuilder&lt;IRunOutDiscountForProducts&gt;.ScopeIsolation()
        }))
    {
        products = repo.Get&lt;IRunOutDiscountForProducts&gt;();
        <span style="color: #0000ff">foreach</span> (var product <span style="color: #0000ff">in</span> products)
        {
            product.DiscountProductForRunOut();
        }

        scope.Complete();
    }
}</pre>
</div>
<p>Figure 1.0 demonstrates how all the moving parts in the developer experience are put to use when using the NFetchSpec libraries to query and make changes to a persisted Domain Model. Let’s now examine in detail all the steps that make up the entire developer experience of composing all the discrete pieces needed in addressing the role of <strong><em>IRunOutDiscountForProducts</em></strong> (in our fictitious system).</p>
<h2><span style="text-decoration: underline">The Development Scenario</span></h2>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image-thumb.png" width="37" height="38" /></a> The first outlined section in figure 1.0 demonstrates the building of an appropriate ObjectContext for the Repository that is instantiated by the fluent interface. From the developer experience perspective, nothing special needs to be done outside of specifying the role to the fluent interface in this manner.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image1.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image-thumb1.png" width="37" height="38" /></a> The second outlined section in figure 1.0 highlights how the role is leveraged to dynamically have NFetchSpec chose the ‘<strong>right</strong>’ isolation level. Being explicit in this way we can achieve a high degree of separation of concerns with respect to transaction isolation and thus exercise our control over the concurrency and throughput in the database on a role by role basis. In the example, we are discounting products earmarked for a run out sale, consequently changing their unit price, therefore we might like to choose a higher isolation level for that particular operation, depending on the volatility of the data that your dealing with and the normalization or lack thereof in your database schema. For the developer this means creating a concrete implementation of the interface <strong><em>IProvideIsolationLevelFor&lt;T&gt;</em></strong>, to support this automagic behaviour.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> interface IProvideIsolationLevelFor&lt;TRole&gt;
{
    IsolationLevel GetScopeIsolationForRole { <span style="color: #0000ff">get</span>;}
}

<span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> RunoutDiscountIsolation :
             IProvideIsolationLevelFor&lt;IRunOutDiscountForProducts&gt;
{
    <span style="color: #0000ff">public</span> IsolationLevel GetScopeIsolationForRole
    {
        <span style="color: #0000ff">get</span> { <span style="color: #0000ff">return</span> IsolationLevel.ReadCommitted; }
    }
}</pre>
</div>
<p>That’s it as far as getting your transaction set for the right Isolation Level within the scope of work for a given role. If we decide at some point that this Isolation Level is not the best fit, we can replace it with a new implementation.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image2.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image-thumb2.png" width="37" height="38" /></a> The Third outlined section in figure 1.0 highlights the use of the Repository to retrieve the Entities that we are interested in. This is where the NFetchSpec machinery goes to work to resolve all the purpose built artefacts that have been implemented for the given role, such as any applicative Fetching Strategy, Specification, Entity and Mapping.</p>
<h3><span style="text-decoration: underline">The Loaded Fetching Strategy</span></h3>
<p><span style="text-decoration: underline"></span></p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ProductRunOutFetchingStrategy :
             FetchingStrategy&lt;IRunOutDiscountForProducts&gt;
{
    <span style="color: #0000ff">public</span> ProductRunOutFetchingStrategy()
        : base(<span style="color: #0000ff">false</span>)
    {
        var production_intentions =
            EagerFetchingIntention
            .CreateInstance&lt;IRunOutDiscountForProducts,
                            ISupplier&gt;(p =&gt; p.Supplier);

        this.AddIntentions(<span style="color: #0000ff">new</span> IEagerFetchingIntention[]
        {
            production_intentions
        });
    }
}</pre>
</div>
<p>The intent of the developer in building this Fetching Strategy is to load Products eagerly with their reference Supplier.</p>
<h3><span style="text-decoration: underline">The Loaded Specification</span></h3>
<p><span style="text-decoration: underline"></span></p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> RunOutProductDiscountSpecification :
             Specification&lt;IRunOutDiscountForProducts&gt;
{
    <span style="color: #0000ff">public</span> RunOutProductDiscountSpecification()
        : base(p =&gt; p.UnitPrice &gt; 5M) { }
}</pre>
</div>
<p>The Specification is really quite simple and self evident – setting up the applicative Expression that will ultimately be translated into a ‘where’ predicate.</p>
<h3><span style="text-decoration: underline">The Loaded Mapping</span></h3>
<p>First up we need to map our Entities and that requires a Mapping&lt;T&gt;.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ProductMapping : Mapping&lt;Product&gt;
{
    <span style="color: #0000ff">public</span> ProductMapping(string objectSetName) : base(objectSetName)
    {
        Property(p =&gt; p.ProductID).IsIdentity();
        Property(p =&gt; p.ProductName).HasMaxLength(50).IsRequired();
        Property(p =&gt; p.UnitPrice).<span style="color: #0000ff">Precision</span> = 19;
        Property(p =&gt; p.UnitPrice).Scale = 4;
        Relationship(p =&gt; p.Supplier).IsOptional();
        Relationship(p =&gt; p.Supplier).IsOptional().FromProperty(s =&gt; s.Products);
    }
}</pre>
</div>
<p>And because our example has a reference Entity in the root we require the following <strong><em>Supplier</em></strong> Entity Mapping also.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> SupplierMapping : Mapping&lt;Supplier&gt;
{
    <span style="color: #0000ff">public</span> SupplierMapping(string objectSetName)
        : base(objectSetName)
    {
        Property(s =&gt;  s.SupplierID).IsIdentity();
        Property(s =&gt; s.CompanyName).HasMaxLength(40).IsRequired();
        Property(s =&gt; s.Region).HasMaxLength(15);
        Relationship(s =&gt; s.Products).IsOptional().FromProperty(p =&gt; p.Supplier);
    }
}</pre>
</div>
<p>The last requirement of the developer with respect to mapping is to create a MappingRole&lt;T&gt;, the purpose of which is to indicate to the infrastructure which mappings are applicable to the Role.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> RunOutDiscountMappingRole :
             IMappingRole&lt;IRunOutDiscountForProducts&gt;
{
    private IMapping[] _mappings;

    <span style="color: #0000ff">public</span> RunOutDiscountMappingRole()
    {
        _mappings = <span style="color: #0000ff">new</span> IMapping[]
                    {
                        <span style="color: #0000ff">new</span> ProductMapping(&quot;Products&quot;),
                        <span style="color: #0000ff">new</span> SupplierMapping(&quot;Suppliers&quot;)
                    };
    }

    <span style="color: #0000ff">public</span> IMapping[] Mappings
    {
        <span style="color: #0000ff">get</span> { <span style="color: #0000ff">return</span> _mappings; }
    }
}</pre>
</div>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image3.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/image-thumb3.png" width="37" height="38" /></a> The fourth and final outlined section in figure 1.0 is really the essence of what is going on here, it is entirely the reason this code is being invoked – it is the purpose (discounting products) of the system for this role. When developing in this way we need to specify the behaviour of the Role through the stable abstraction of it’s interface, and implement that behaviour in a concrete Entity.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> interface IRunOutDiscountForProducts : IProductData
{
    void DiscountProductForRunOut();
}</pre>
</div>
<p><span style="text-decoration: underline"></span></p>
<h2><span style="text-decoration: underline">The Bang and Crash</span></h2>
<p>So with all that done, we need to deploy our “Role inspired” artefacts to the executing processes assemblies folder and when it’s all said and done the code from Figure 1.0 executes, enlisting the service of NFetchSpec in applying the combined intent and customised behaviours described in all of the deployed pieces.</p>
<p>From the database perspective, SQL Profiler tells us that our intent for this ROLE has been met and the system has behaved precisely as expected.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SELECT</span>
    [Extent1].[ProductID] <span style="color: #0000ff">AS</span> [ProductID],
    [Extent1].[ProductName] <span style="color: #0000ff">AS</span> [ProductName],
    [Extent1].[UnitPrice] <span style="color: #0000ff">AS</span> [UnitPrice],
    [Extent2].[CompanyName] <span style="color: #0000ff">AS</span> [CompanyName],
    [Extent2].[Region] <span style="color: #0000ff">AS</span> [Region],
    [Extent2].[SupplierID] <span style="color: #0000ff">AS</span> [SupplierID]
<span style="color: #0000ff">FROM</span>
    [dbo].[Products] <span style="color: #0000ff">AS</span> [Extent1]
<span style="color: #0000ff">LEFT</span> <span style="color: #0000ff">OUTER</span> <span style="color: #0000ff">JOIN</span>
    [dbo].[Suppliers] <span style="color: #0000ff">AS</span> [Extent2]
<span style="color: #0000ff">ON</span>
    [Extent1].[SupplierID] = [Extent2].[SupplierID]
<span style="color: #0000ff">WHERE</span>
    [Extent1].[UnitPrice] &gt; <span style="color: #0000ff">cast</span>(5 <span style="color: #0000ff">as</span> <span style="color: #0000ff">decimal</span>(18))</pre>
</div>
<p><strong><u></u></strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="400">
<p><strong><u>UPDATE: 14th March 2010</u></strong> </p>
<p>The query above was pasted in error previously. The current text for the TSQL here is correct as of the date listed here in this update.</p>
</td>
</tr>
</tbody>
</table>
<p>We can see that Fetching Strategy and Specification have been successful in shaping the TSQL sent to the server to retrieve the data. Below we can also see the effect of applying the business rules through our Domain Model.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">exec</span> sp_executesql N<span style="color: #006080">&#8216;update [dbo].[Products]
set [UnitPrice] = @0
where ([ProductID] = @1)
&#8216;</span>,N<span style="color: #006080">&#8216;@0 decimal(19,4),@1 int&#8217;</span>,@0=3.2960,@1=1</pre>
</div>
<p><span style="text-decoration: underline"></span></p>
<h2><span style="text-decoration: underline">Just one more thing</span></h2>
<p>Part 4.0 will be the final part in the series and will focus on how this approach blends into a service layer in a Service Oriented Architecture and also make the code for NFetchSpec available for download.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Helping%20Entity%20Framework%20v4.0%20play%20it%26rsquo%3Bs%20%3CROLE%3E%20%26ndash%3B%20Part%203.0&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F02%2F21%2Fhelping-entity-framework-v40-play-its-role-part-30%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Helping Entity Framework v4.0 play it&rsquo;s <ROLE> &ndash; Part 3.0";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/">Helping Entity Framework v4.0 play it&rsquo;s &lt;ROLE&gt; &ndash; Part 3.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Doing .NET Days March 6th Fully Booked.</title>
		<link>http://www.simonsegal.net/blog/2010/02/18/doing-net-days-march-6th-fully-booked/</link>
		<comments>http://www.simonsegal.net/blog/2010/02/18/doing-net-days-march-6th-fully-booked/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 14:13:00 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[doing .Net Days]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/02/17/doing-net-days-march-6th-fully-booked/</guid>
		<description><![CDATA[ Doing .Net Days for March 6th 2010 is now fully booked. Thanks to all those who have registered. It’s becoming apparent that the current venue may not be large enough to accommodate the interest moving forward so we are exploring alternative venues and will keep you up date as news comes to hand.
We are [...]<p><a href="http://www.simonsegal.net/blog/2010/02/18/doing-net-days-march-6th-fully-booked/">Doing .NET Days March 6th Fully Booked.</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/20pc-black1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="20pc_black" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/20pc-black-thumb1.png" border="0" alt="20pc_black" width="96" height="81" align="left" /></a> Doing .Net Days for March 6th 2010 is now <a href="http://www.simonsegal.net/blog/training/">fully booked</a>. Thanks to all those who have registered. It’s becoming apparent that the current venue may not be large enough to accommodate the interest moving forward so we are exploring alternative venues and will keep you up date as news comes to hand.</p>
<p>We are also in the throws of putting together the web site for the event which will be announce shortly.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Doing%20.NET%20Days%20March%206th%20Fully%20Booked.&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F02%2F18%2Fdoing-net-days-march-6th-fully-booked%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Doing .NET Days March 6th Fully Booked.";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/02/18/doing-net-days-march-6th-fully-booked/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/02/18/doing-net-days-march-6th-fully-booked/">Doing .NET Days March 6th Fully Booked.</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/02/18/doing-net-days-march-6th-fully-booked/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Helping Entity Framework v4.0 play it&#8217;s &#60;ROLE&#62; - Part 2.0</title>
		<link>http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/</link>
		<comments>http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 01:53:59 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DDD]]></category>

		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[Patterns &amp; Practices]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/</guid>
		<description><![CDATA[The content of this series of posts is based around a spiking effort / proof of concept that aims to modularize (I am avoiding the word framework) a set of libraries for the express purpose of addressing business intent for Domain models persisted with the Entity Framework. In part 1.0 we laid the groundwork and [...]<p><a href="http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/">Helping Entity Framework v4.0 play it&rsquo;s &lt;ROLE&gt; - Part 2.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>The content of this series of posts is based around a spiking effort / proof of concept that aims to modularize (I am avoiding the word framework) a set of libraries for the express purpose of addressing business intent for Domain models persisted with the Entity Framework. In <a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/">part 1.0</a> we laid the groundwork and now we dig deeper.</p>
<p>I’m going to start this post at the end and then rewind all the way to beginning and step through how we got here. Here is some code that will return a list of products and in so doing, will dynamically determine the correct Entity type to return (a Product), will eagerly fetch their reference supplier and will apply a ‘where’ predicate to the LINQ To Entities query. All this will happen out of clear view as a result of being explicit and specifying a role / interface to the ORM when we ask it do something.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> Some_Method_In_My_Service_Layer
{
    var products = Repository.Get&lt;IRunOutDiscountForProducts&gt;();
}</pre>
</div>
<p>Now let’s briefly forget we saw this code and go back to the start.</p>
<p>Lets start by imagining some simple data access code that’s enormously compact and equally deceptive in it’s apparent simplicity. For a scenario, let’s propose that we want to get all the products in our system that are eligible for applying a run out discount. The business logic in achieving this function, specifies that a Products Unit Price Price  be greater 20.50 dollars and is purchased from suppliers in a given enumerable list of regions. For the sake of the example we will also say that this would require a Product entity and Supplier Entity in the following relationship.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/product-supplier-class-diag.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="product_supplier_class_diag" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/product-supplier-class-diag-thumb.png" border="0" alt="product_supplier_class_diag" width="447" height="253" /></a></p>
<p>So given our the scenario we would be required to map the Entities appropriately, choose an appropriate method of loading (lazy or eager) and apply a suitable predicate to the SQL query. Let’s now imagine that by specifying a role (in this case the interface <strong><em>IRunOutDiscountForProducts</em></strong>), that we have provided the infrastructure code enough information to query the database for products and do so in a way that meets the proposed scenario requirements enumerated above.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var conParams = <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt;();
conParams .Add(_conParamName, _connectionStringOnly);

var repository = FetchSpec.Configure
                    .With(<span style="color: #0000ff;">new</span> StubIoc()
                        { ScannedAssemblyPath = _scannedAssemblyPath })
                    .AndBuildSession&lt;IRunOutDiscountForProducts&gt;(conParams)
                    .ForRepository();

var products = repository.Get&lt;IRunOutDiscountForProducts&gt;();</pre>
</div>
<p>The line of code that interests us most at this point is the last one. By applying the role of <strong><em>IRunOutDiscountForProducts </em></strong>to the GET&lt;T&gt; function<strong><em>,</em></strong> we are able to indicate to the infrastructure that our intent is to retrieve a list of Products for the express reason to apply a ‘run out’ discount to them. The next line of code you might expect to see would logically be something like:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">products = repo.Get&lt;IRunOutDiscountForProducts&gt;();
<span style="color: #0000ff;">foreach</span> (var product <span style="color: #0000ff;">in</span> products)
{
    product.DiscountProductForRunOut();
}

repo.Save();</pre>
</div>
<p>What figure 1.0 shows is that we would like our Repository to be smart enough to know exactly what and how to fetch based on the role (the generic parameterized interface).</p>
<h3><span style="text-decoration: underline;">Figure 1.0</span></h3>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/explicit-concerns.gif" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="explicit_concerns" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/explicit-concerns-thumb.gif" border="0" alt="explicit_concerns" width="448" height="208" /></a></p>
<p>I promise we will get to the end soon enough but bear with me for a minute or two. One thing about being explicit with roles, it makes understanding code all the more simple. The less ambiguity the less likely someone misunderstands intent. In the realm of software development the humble interface (not the UI kind) has carried the torch ably in helping us declare our intent more explicitly, make our code better understood and free of concrete dependencies / coupling. With reverence and honour for my past (COM programming veteran status), I apologise in advance for the ubiquitous IDog example but it makes a point.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> Poodle : IDog
{
    <span style="color: #008000;">//&#8230;.etc</span>
}</pre>
</div>
<p>Explicitly a Poodle must now conform polymorphically et al to the contract specified by IDog – real 101 stuff no doubt. What about a marker interface? True enough, a very useful construct, bereft of polymorphic intent and largely a utility to express membership to a conceptual entity group of some kind, often put to use in frameworks to support dynamism of some description. Let’s use an NServiceBus IMessage as an example:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IMessage {}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> OrderCancelledMessage : IMessage
{
    <span style="color: #008000;">//&#8230;.etc</span>
}</pre>
</div>
<p>Without going too deep into this at a code level, suffice to say that the NServiceBus infrastructure will behave in certain ways when it comes across types that implement the IMessage interface, in other words the framework is directing us to ‘mark’ a given class (or interface) as being recognizable as a ‘Message’, making it identifiable to the frameworks internal workings.</p>
<p>The virtues of programming by interface are now well documented and for .NET developers the advent and popularity of generics has encouraged our creativity in placing stable abstractions  around things to make code more explicit. For example, a while back I wrote in the abstract on the use of interfaces to define roles; roles describe the polymorphic nature of a business domain command and arguably event. This series of posts is an extension of <a href="http://www.simonsegal.net/index.php?s=roles&amp;sbutt=Go">those made in the past</a>, the focus however now moves to a proof of concept for the up coming Entity Framework 4.0.</p>
<h3><span style="text-decoration: underline;">What is a Role?</span></h3>
<p>Roles identify or describe commands / behaviours in the domain, an level of intent that can be be nicely defined by an interface.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IRunOutDiscountForProducts : IProductData
{
    <span style="color: #0000ff;">void</span> DiscountProductForRunOut();
}</pre>
</div>
<p>We can use these roles (interfaces) to indicate to our infrastructure (an ORM in this case) what our intent is and have the infrastructure behave appropriately based on configuration and / or convention.</p>
<p>Since we started with an example that focused around products, lets continue with that subject for a moment. It may be that my system needs to fetch Products for a variety of reasons and not always with the same intent. We shouldn’t be asking for a generic list of Products, considering that we are interested in them with a very specific context in mind and its the context determines the behaviour and describes the a role.</p>
<p>Once our system becomes explicit in this way through the use of roles in our domain, we can do some interesting things. We can instruct the ORM how to load the entity graph by implementing Fetching Strategies, dynamically resolve the most appropriate Entity Mapping to use and which predicate to apply to the query for the purpose of business logic filtering. Not only does the the role provide a stable abstraction, it insulates other parts of the architecture, perhaps a service layer or controller, from changes, allowing the actors to vary independently.</p>
<h3><span style="text-decoration: underline;">The Roles Quadrant:</span></h3>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/quadrant-roles.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="quadrant_roles" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/quadrant-roles-thumb.png" border="0" alt="quadrant_roles" width="456" height="212" /></a></p>
<p>Whilst working on this proof of concept in my attempts at cajoling the Entity Framework to work in this fashion, it became evident that there were four main pieces of the puzzle, Fetching Strategies, Specifications, Mapping, and Repositories. One thing that I haven’t mentioned yet, is the effect on concurrency, scale and throughput that this approach can have. Through the use of roles we can plug into the architecture yet again and explicitly pick an isolation level for the operation at hand.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">using</span> (var scope = <span style="color: #0000ff;">new</span> TransactionScope(TransactionScopeOption.Required,
    <span style="color: #0000ff;">new</span> TransactionOptions()
    {
        IsolationLevel =
            SessionBuilder&lt;IRunOutDiscountForProducts&gt;.ScopeIsolation()
    }))
{
    <span style="color: #008000;">//&#8230;..do some stuff here like load data </span>
    <span style="color: #008000;">//&#8230;..change data by calling into your domain model</span>
    <span style="color: #008000;">//&#8230;..and finally save the changes</span>

    scope.Complete();
}</pre>
</div>
<p>Notice that in constructing the Transaction scope we use the SessionBuilder and ask it to supply an Isolation Level for the role specified. Of course their is some IOC magic involved here but essentially the only thing required to make work is the following interface. Here is an example implementation.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IProvideIsolationLevelFor&lt;TRole&gt;
{
    IsolationLevel GetScopeIsolationForRole { get;}
}

<span style="color: #008000;">///Implementation</span>

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> RunoutDiscountIsolation :
    IProvideIsolationLevelFor&lt;IRunOutDiscountForProducts&gt;
{
    <span style="color: #0000ff;">public</span> IsolationLevel GetScopeIsolationForRole
    {
        get { <span style="color: #0000ff;">return</span> IsolationLevel.ReadCommitted; }
    }
}</pre>
</div>
<div>This concrete class is responsible (explicitly) for providing the correct isolation level for the <strong><em>IRunOutDiscountForProducts</em></strong> role.</div>
<h3><span style="text-decoration: underline;">Loaded Up</span></h3>
<div>Before looking at each of the four corners of the quadrant, I quickly want to draw your attention to the fact that Specifications, Fetching Strategies, Isolation Levels (for Transactions), Entities and indeed even their Mappings, can all be resolved from a container at runtime, based on the given role.</div>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">_container.Register(AllTypes
    .Of(<span style="color: #0000ff;">typeof</span>(IFetchingStrategy&lt;&gt;))
    .FromAssembly(assembly)
    .Configure(c =&gt; c.LifeStyle.Singleton).WithService.FirstInterface());

_container.Register(AllTypes
    .Of(<span style="color: #0000ff;">typeof</span>(ISpecification&lt;&gt;))
    .FromAssembly(assembly)
    .Configure(c =&gt; c.LifeStyle.Singleton).WithService.FirstInterface());

_container.Register(AllTypes
    .Of(<span style="color: #0000ff;">typeof</span>(IMappingRole&lt;&gt;))
    .FromAssembly(assembly)
    .Configure(c =&gt; c.LifeStyle.Singleton).WithService.FirstInterface());

_container.Register(AllTypes
    .Of(<span style="color: #0000ff;">typeof</span>(IProvideIsolationLevelFor&lt;&gt;))
    .FromAssembly(assembly)
    .Configure(c =&gt; c.LifeStyle.Singleton).WithService.FirstInterface());

_container.Register(AllTypes
    .Of(<span style="color: #0000ff;">typeof</span>(IEntity))
    .FromAssembly(assembly));</pre>
</div>
<div>This will make the understanding an little easier as we move through the rest of the post.</div>
<h3><span style="text-decoration: underline;">Quadrant Position 1.0 – Fetching Strategies</span></h3>
<p>Fetching strategies encapsulate our expression of requirement with respect to Eager and Lazy Loading. This feature is useful, when one considers that the Entity Framework (and most ORM’s for that matter) do not provide these capabilities with a consistent API experience, nor allow for an out of box experience friendly to a configurable or convention based approach to specifying loading characteristics for a given expression of intent. Wouldn’t it be nice if we could ask the ORM to fetch an Entity using a role, one specific to a command that exists within a given business capability? This functionality does exist with NHibernate but not currently with either version of Entity Framework, but the good news is that it is possible. There are a couple of ways of doing this and I have <a href="http://www.simonsegal.net/index.php?s=Fetching+strategy&amp;sbutt=Go">blogged</a> about it more than once. At this point of the discussion it would be useful to show some code and how to configure a Fetching Strategy. First the interface:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IFetchingStrategy&lt;TRole&gt; : IQueryConfigurable
{
    IEnumerable&lt;IEagerFetchingIntention&gt; Intentions { get; }
    IEnumerable&lt;<span style="color: #0000ff;">string</span>&gt; Includes { get; }
    <span style="color: #0000ff;">void</span> AddIntentions(IEagerFetchingIntention[] intentions);
    <span style="color: #0000ff;">bool</span> ShouldLazyLoad { get; }
    <span style="color: #0000ff;">bool</span> HasInstructions { get; }
}</pre>
</div>
<p>Next let’s look at an implementation (we will skip the base class for now).</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> CustomerPreferedFetchingStratey :
             FetchingStrategy&lt;IMakeCustomerPrefered&gt;
{
    <span style="color: #0000ff;">public</span> CustomerPreferedFetchingStratey()
        : <span style="color: #0000ff;">base</span>(<span style="color: #0000ff;">false</span>) {

            var orders_intention =
                EagerFetchingIntention
                .CreateInstance&lt;IMakeCustomerPrefered,
                                ICollection&lt;IOrder&gt;&gt;(c =&gt; c.Orders);
            var orderlines_intention =
                EagerFetchingIntention
                .CreateInstance&lt;IOrder,
                                ICollection&lt;IOrderLine&gt;&gt;(o =&gt; o.OrderLines);

            <span style="color: #0000ff;">this</span>.AddIntentions(<span style="color: #0000ff;">new</span> IEagerFetchingIntention[]
            {
                orders_intention,
                orders_intention.And(orderlines_intention)
            });
    }
}</pre>
</div>
<div>Without dwelling on all the moving parts, let’s summarise here by saying that this code has the responsibility of building up the ‘includes’ strings<strong><em> </em></strong>(<strong><em>see ObjectContext&lt;T&gt;.Include()</em></strong>) for eager fetching. No more magic strings applied to the ObjectContext.Include(“magic.more.magic”) method. With a Fetching Strategy we can determine our eager fetching in a strongly type fashion by explicitly specify a role to the Fetching Strategy. In this case above, we are using the <strong><em>IMakeCustomerPrefered</em></strong> role.</div>
<h3><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;">Quadrant </span>Position</span> 2.0 – Specification</span></h3>
<p>The <a href="http://en.wikipedia.org/wiki/Specification_pattern">Specification pattern</a> evolved around the problem of testing that the state condition of an object is met according to a given specification. This pattern has taken on some new potential with the help of LINQ. Using LINQ Expressions it’s possible to massage this pattern into something of a predicate store and when we think about developing with roles it becomes potentially more powerful again. Here is a quick look at a Specification and some usage:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var spec = <span style="color: #0000ff;">new</span> Specification&lt;IRunOutDiscountForProducts&gt;
              (p =&gt; p.UnitPrice &lt; 20M &amp;&amp; p.Supplier.Region == “London”);</pre>
</div>
<p>Pretty simple, the constructor takes the Expression to initialise the boolean test for the specified state. The classical purpose of the pattern is to provide a single function, commonly named “IsSatisfied” to carry out the test against a given object to see if it’s state indeed meets that that has been specified.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var productToTest = <span style="color: #0000ff;">new</span> Product(){Supplier = <span style="color: #0000ff;">new</span> Supplier()};
var satisfied = spec.IsSatisfiedBy(productToTest);</pre>
</div>
<p>This will code will obviously fail the specification test and IsSatisfiedBy() will return false. Whilst very useful in and of itself, the LINQ Expression enabled version / implementation of this pattern has some features that can be harnessed to apply a level of dynamism to the resolution of query predicates. Let’s have a closer look:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> ISpecification&lt;T&gt; : IQueryConfigurable
{
    Expression&lt;Func&lt;T, <span style="color: #0000ff;">bool</span>&gt;&gt; EvalPredicate { get; }
    Func&lt;T, <span style="color: #0000ff;">bool</span>&gt; EvalFunc { get; }
    <span style="color: #0000ff;">bool</span> IsSatisfiedBy(T entity);
}</pre>
</div>
<p>The interface details the contract to provide both the Expression and Func that will provide the computation required to discern whether a specification has been satisfied. Further to that, these new properties give us opportunities to plug predicates or lambdas into the machinery as well. Looking a little deeper under the covers of the proof of concept code we will find this in operation:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">return</span> _ctx
       .CreateObjectSet&lt;TRole&gt;()
       .Where(predicate.EvalPredicate)
       .ToList();</pre>
</div>
<p>Through operator overloading, Specifications can also be combined for OR and AND conditions:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">Specification&lt;Customer&gt; german_customer_spec =
    <span style="color: #0000ff;">new</span> Specification&lt;Customer&gt;(c =&gt; c.Country == “Germany”);

Specification&lt;Customer&gt; us_customer_spec =
    <span style="color: #0000ff;">new</span> Specification&lt;Customer&gt;(c =&gt; c.Country == “Usa”);

var comb_country_spec = (german_customer_spec | us_customer_spec);</pre>
</div>
<p>In the case where query predicates help to form a semi static business rule at the query level through filtering, it becomes a reasonably trivial task to deploy a new version or entirely new Specification for any given role, simply by deploying the library.</p>
<h3><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;">Quadrant </span>Position</span> 3.0 – Mapping</span></h3>
<p>Now to the latest part of the puzzle to be rolled into the Proof of concept, mapping. Entity Framework 4.0 (sometime after initial release) will be augmented by code only mapping (hallelujah). When one looks at the (current CTP) API for this functionality it becomes immediately evident that this too is something that can be very easily made deterministic by adding a layer of indirection to accommodate this role based approach. The out of the box mapping in EF 4.0 makes working in this manner quite simple given the possibilities provided by the EntityConfiguration&lt;T&gt; class. Here is a simple example:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> CustomerMapping : EntityConfiguration&lt;ICustomer&gt;
{
    <span style="color: #0000ff;">public</span> CustomerMapping()
    {
        Property(c =&gt; c.CustomerId).IsIdentity();
        Property(c =&gt; c.FirstName).HasMaxLength(50).IsRequired();
        Property(c =&gt; c.LastName).HasMaxLength(50).IsRequired();
        Relationship(c =&gt; c.Orders).IsOptional();
        Relationship(c =&gt; c.Orders).FromProperty(o =&gt; o.Customer);
    }
}</pre>
</div>
<p>What’s required is to take this out of the box solution and add a layer of indirection requiring only a few new actors, an IMapping, an IMappingRole&lt;T&gt;  and a Mapping&lt;T&gt;.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/mappingrolesconcept.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="mappingRolesConcept" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/mappingrolesconcept-thumb.png" border="0" alt="mappingRolesConcept" width="397" height="365" /></a></p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IMapping
{
    Type EntityType { get; }
    <span style="color: #0000ff;">string</span> ObjectSetName { get; }
    StructuralTypeConfiguration Configuration { get; }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IMappingRole&lt;TRole&gt;
{
    IMapping[] Mappings { get; }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">abstract</span> <span style="color: #0000ff;">class</span> Mapping&lt;TEntity&gt; :
                      EntityConfiguration&lt;TEntity&gt;, IMapping
{
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">string</span> _objectSetName;

    <span style="color: #0000ff;">public</span> Type EntityType
    {
        get { <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">typeof</span>(TEntity); }
    }

    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> ObjectSetName
    {
        get { <span style="color: #0000ff;">return</span> _objectSetName; }
    }

    <span style="color: #0000ff;">public</span> Mapping(<span style="color: #0000ff;">string</span> objectSetName)
    {
        _objectSetName = objectSetName;
    }

    <span style="color: #0000ff;">public</span> StructuralTypeConfiguration Configuration
    {
        get { <span style="color: #0000ff;">return</span> (StructuralTypeConfiguration)<span style="color: #0000ff;">this</span>; }
    }
}</pre>
</div>
<p>The aggregation of IMapping’s in the Mapping Role will accommodate mapping an aggregate root with reference and collection entities. Here’s a more complete look that includes some implementing Mapping classes.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/mappingrolesclassdiag.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="mappingRolesClassDiag" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/mappingrolesclassdiag-thumb.png" border="0" alt="mappingRolesClassDiag" width="496" height="517" /></a></p>
<p>Below is an example Mapping class, notice that we still need to use the actual Entity Type and not an interface. This is due to EntityConfiguration&lt;T&gt; lacking in support for interfaces (as of today, perhaps that will change or already has with RC 1).</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> ProductMapping : Mapping&lt;Product&gt;
{
    <span style="color: #0000ff;">public</span> ProductMapping(<span style="color: #0000ff;">string</span> objectSetName) : <span style="color: #0000ff;">base</span>(objectSetName)
    {
        Property(p =&gt; p.ProductID).IsIdentity();
        Property(p =&gt; p.ProductName).HasMaxLength(50).IsRequired();
        Property(p =&gt; p.UnitPrice).Precision = 19;
        Property(p =&gt; p.UnitPrice).Scale = 4;
        Relationship(p =&gt; p.Supplier).IsOptional();
        Relationship(p =&gt; p.Supplier).IsOptional().FromProperty(s =&gt; s.Products);
    }
}</pre>
</div>
<h3></h3>
<h3></h3>
<h3><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;">Quadrant </span>Position</span> 4.0 – The Repository</span></h3>
<p>The final square on the grid is the Repository. The repository offers nothing more than five overrides of the one method, Get&lt;T&gt;. The five versions of the method are to cover the variable requirements that might crop up when consumers wish to provide Fetching Strategies, Specifications and Entities (concrete ones) inline and directly to the infrastructure. Fetching Strategies are probably the least likely candidate for this requirement but it may come in useful, Specifications on the other hand will from time to time no doubt be populated dynamically from user input, served as part of a request or message and subsequently used as a filter parameter. Let’s have a brief look at the Interface:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">interface</span> IRepository : IUnitOfWork
{
    IList&lt;TRole&gt; Get&lt;TRole&gt;();
    IList&lt;TRole&gt; Get&lt;TRole&gt;(IQueryConfigurable[] configurables);
    IList&lt;TRole&gt; Get&lt;TRole&gt;(ISpecification&lt;TRole&gt; predicateWhere)
                            <span style="color: #0000ff;">where</span> TRole : <span style="color: #0000ff;">class</span>;
    IList&lt;TRole&gt; Get&lt;TRole&gt;(IFetchingStrategy&lt;TRole&gt; strategy)
                            <span style="color: #0000ff;">where</span> TRole : <span style="color: #0000ff;">class</span>;
    IList&lt;TRole&gt; Get&lt;TRole&gt;(ISpecification&lt;TRole&gt; predicateWhere,
                            IFetchingStrategy&lt;TRole&gt; strategy)
                            <span style="color: #0000ff;">where</span> TRole : <span style="color: #0000ff;">class</span>;
    IoC IocContainer { set; }
    ObjectContext Session { set; }
}</pre>
</div>
<p>The first two versions of Get&lt;T&gt; will resolve as much as they can from the container, a Fetching Strategy, a Specification, the Mapping and will use the closest adjacent Entity type, all based on the identity of the generic parameter – that is, the ROLE. The last three versions of the Get&lt;T&gt; function is provided to work with the Entity Framework in a more familiar mode where and EDMX file can be specified, the concrete Entity Type itself is provided as the role parameter, we can also push through Fetching Strategies and Specifications ‘in-line’ in these scenarios. Probably not my preferred method but it’s available.</p>
<h2><span style="text-decoration: underline;">Configuration</span></h2>
<p>I decided at the death to implement a fluent configuration to prime the infrastructure and create a Repository. The fluent interface is designed with the view to keeping things compact and easy to setup.</p>
<h4><span style="text-decoration: underline;">Resolve it all</span></h4>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> resolves_everything_from_container()
{
    var compParams = <span style="color: #0000ff;">new</span> Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt;();
    compParams.Add(_conParamName, _connectionStringOnly);

    var repo = FetchSpec.Configure
                        .With(<span style="color: #0000ff;">new</span> StubIoc()
                            { ScannedAssemblyPath = _scannedAssemblyPath })
                        .AndBuildSession&lt;IRunOutDiscountForProducts&gt;(compParams)
                        .ForRepository();

    var products = repo.Get&lt;IRunOutDiscountForProducts&gt;();
}</pre>
<p>In this example above, we are using a stub for IoC, and hard wiring the scanned assembly path to find all the implementing Fetching Strategies, Specifications, Mappings etc. The default behaviour in the spiking code is to enumerate the assemblies with the executing processes deployment.</p>
<h3><span style="text-decoration: underline;">Provide it all</span></h3>
<p>For those that like the EDMX way of doing things and want to provide all the Fetching and Speciation instructions in line, this is the way to go about it:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> CustomerBuyingStatusRepository : Repository
{
    <span style="color: #0000ff;">public</span> CustomerBuyingStatusRepository()
    {
        <span style="color: #008000;">//BEWARE THIS STRING WONT COMPILE ITS MESSED UP</span>
        <span style="color: #008000;">//FOR THE PURPOSE OF VIEWING IN THE BROWSER.</span>
        <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">string</span> constring = <span style="color: #006080;">&#8220;metadata=res://*/Northwind.csdl|res://*/&#8221;</span> +
                                 <span style="color: #006080;">&#8220;Northwind.ssdl|res://*/Northwind.msl;&#8221;</span> +
                                 <span style="color: #006080;">&#8220;provider=System.Data.SqlClient;provider &#8220;</span> +
                                 <span style="color: #006080;">&#8220;etc, etc, etc&#8221;</span>;

        <span style="color: #0000ff;">this</span>.IocContainer = <span style="color: #0000ff;">new</span> IoC();
        <span style="color: #0000ff;">this</span>.Session = <span style="color: #0000ff;">new</span> NorthwindEntities(constring);
    }
}

<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> using_concrete_repository_entity_and_inline_spec_and_fetching()
{
    var customersStartWithA =
        <span style="color: #0000ff;">new</span> Specification&lt;Customer&gt;(c =&gt; c.CompanyName.StartsWith(<span style="color: #006080;">&#8220;A&#8221;</span>));

    var fetch = <span style="color: #0000ff;">new</span> FetchingStrategy&lt;Customer&gt;(<span style="color: #0000ff;">true</span>);

    fetch.AddIntentions(<span style="color: #0000ff;">new</span> IEagerFetchingIntention[]
    {
        EagerFetchingIntention.CreateInstance&lt;Customer,
                                              ICollection&lt;IOrder&gt;&gt;(c =&gt; c.Orders)
    });

    var repo = <span style="color: #0000ff;">new</span> CustomerBuyingStatusRepository();

    var custs = repo.Get&lt;Customer&gt;(customersStartWithA, fetch);

    <span style="color: #0000ff;">foreach</span> (var cust <span style="color: #0000ff;">in</span> custs)
    {
        Console.WriteLine(cust.CompanyName);
        cust.MakePrefered();
    }
}</pre>
</div>
<p>I could have easily left out the ability to support this in-line method, given that the purpose of the spike was to proof the role based approach, having it’s greatest value proposition in being resolved dynamically against the Role. Nonetheless it is possible to mix and match or exclusively do either if you absolutely must. No prizes for guessing which mode I am more partial to, however I will reserve final judgement until it gets a good hit out in the real world, remember this is all the result of a brute force spiking effort.</p>
<h3><span style="text-decoration: underline;">What’s Left?</span></h3>
<p>In part 3.0 we will look at concurrency and throughput through the lens of a service layer. I will also make the code download available in part 3.0.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Helping%20Entity%20Framework%20v4.0%20play%20it%26rsquo%3Bs%20%3CROLE%3E%20-%20Part%202.0&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F02%2F17%2Fhelping-entity-framework-v40-play-its-role-part-20%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Helping Entity Framework v4.0 play it&rsquo;s <ROLE> - Part 2.0";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/">Helping Entity Framework v4.0 play it&rsquo;s &lt;ROLE&gt; - Part 2.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Doing .NET Days Announcement</title>
		<link>http://www.simonsegal.net/blog/2010/02/13/doing-net-days-announcement/</link>
		<comments>http://www.simonsegal.net/blog/2010/02/13/doing-net-days-announcement/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 01:46:48 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[doing .Net Days]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/02/13/doing-net-days-announcement/</guid>
		<description><![CDATA[ It’s time to get Doing .NET Days off and running for 2010 and whilst we were originally expecting to be running on the 27th of February it has proven difficult to book the training facility for that date. Therefore I can announce that Saturday the 6th of March is locked in and finalised. Please [...]<p><a href="http://www.simonsegal.net/blog/2010/02/13/doing-net-days-announcement/">Doing .NET Days Announcement</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/20pc-black.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="20pc_black" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/20pc-black-thumb.png" border="0" alt="20pc_black" width="119" height="94" align="left" /></a> It’s time to get <a href="http://www.simonsegal.net/blog/training/">Doing .NET Days</a> off and running for 2010 and whilst we were originally expecting to be running on the 27th of February it has proven difficult to book the training facility for that date. Therefore I can announce that Saturday the 6th of March is locked in and finalised. Please accept our apologies if your plans have been affected by the change of date. You can visit this <a href="http://www.simonsegal.net/blog/training/">link</a> and register via email. Remember seats are fairly limited so if you wish to attend don’t put it off if you can help it.</p>
<p>The topics covered this time around are ‘Helping the Entity Framework play its &lt;ROLE&gt;’, looking at ways of using behavioural roles defined by interfaces in your system to be explicit and achieve lower latency, greater throughput, more highly testable and maintainable code . The second topic will be a practical look at getting started with NServiceBus, including demonstrations taking in messaging patterns such as Publish / Subscribe and full duplex.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Doing%20.NET%20Days%20Announcement&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F02%2F13%2Fdoing-net-days-announcement%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Doing .NET Days Announcement";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/02/13/doing-net-days-announcement/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/02/13/doing-net-days-announcement/">Doing .NET Days Announcement</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/02/13/doing-net-days-announcement/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IronPython and the Entity Framework Part 5.0 &#8211; Concluded</title>
		<link>http://www.simonsegal.net/blog/2010/02/06/ironpython-and-the-entity-framework-part-50-concluded/</link>
		<comments>http://www.simonsegal.net/blog/2010/02/06/ironpython-and-the-entity-framework-part-50-concluded/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 10:34:01 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/02/06/ironpython-and-the-entity-framework-part-50-concluded/</guid>
		<description><![CDATA[This is the final part of the series on using IronPython together with the Entity Framework.
Part 1.0
In this first instalment we setup the discussion on what we were trying achieve, how to use the __clrtype__ class in IronPython 2.6 to create PODO’s (Plain Old Dlr Objects) ala POCO, for integration with the Entity Framework. Our [...]<p><a href="http://www.simonsegal.net/blog/2010/02/06/ironpython-and-the-entity-framework-part-50-concluded/">IronPython and the Entity Framework Part 5.0 &ndash; Concluded</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is the final part of the series on using IronPython together with the Entity Framework.</p>
<h3><u><a href="http://www.simonsegal.net/blog/2009/12/31/entity-framework-ironpython-and-podos-can-it-be-done-part-1/">Part 1.0</a></u></h3>
<p>In this first instalment we setup the discussion on what we were trying achieve, how to use the __clrtype__ class in IronPython 2.6 to create PODO’s (<strong><u>P</u></strong>lain <strong><u>O</u></strong>ld <strong><u>D</u></strong>lr <strong><u>O</u></strong>bjects) ala POCO, for integration with the Entity Framework. Our aim is to use the Entity Framework using the Beta 2 of Entity Framework 4.0.</p>
<h3><u><a href="http://www.simonsegal.net/blog/2010/01/07/entity-framework-ironpython-and-podos-can-it-be-done-part-2/">Part 2.0</a></u></h3>
<p>We dig in deep and explore the internals of what’s required to create a PODO (POCO for the DLR). We also build an IronPython ObjectContext and determine how to manage mapping between the Entities and Database. We achieve a successful test run and prove that we can in simple cases get IronPython and Entity Framework to worth together in this fashion. Finally in part 2.0 we take steps to verify lazy loading for an entity graph and we strike our first hurdle, leaving us to look forward to part 3 to see if the problems encountered might be overcome.</p>
<h3><u><a href="http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/">Part 3.0</a></u></h3>
<p>We start to examine the issues with scalar / native types and see how proxies fit into the puzzle. We check out eager loading and whilst we do have some success we still face a problem in rounding out the whole story. Finally we prepare to journey into debugging a crash dump file for part 4.</p>
<h3><u><a href="http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/">Part 4.0</a></u></h3>
<p>Using Visual Studio 2010 we successfully load up our crash dump file in the hope of jumping over the final hurdle. We discover that the specialized version of IronPython 2.6 does not have publicly available debug symbols but we can manage to see where the active thread was when the fatal crash occurred. </p>
<h2>The State of Play</h2>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/squarepegroundhole.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="squarepegroundhole" border="0" alt="squarepegroundhole" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/squarepegroundhole-thumb.png" width="198" height="215" /></a> The current set of problems unfortunately leaves us short in terms of using the Entity Framework from IronPython, however I did previously demonstrate (in two parts <a href="http://www.simonsegal.net/blog/2009/02/08/ironruby-and-the-entity-framework-part-1/">here</a> and <a href="http://www.simonsegal.net/blog/2009/03/11/ironruby-and-the-entity-framework-part-2/">here</a>) how this can be achieved by way of introducing an interop layer with C# addressing the Entity Framework.</p>
<p><a href="http://www.simonsegal.net/blog/2009/12/31/entity-framework-ironpython-and-podos-can-it-be-done-part-1/">Part 1.0</a></p>
<p><a href="http://www.simonsegal.net/blog/2010/01/07/entity-framework-ironpython-and-podos-can-it-be-done-part-2/">Part 2.0</a></p>
<p><a href="http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/">Part 3.0</a></p>
</p>
<p><a href="http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/">Part 4.0</a></p>
<p>It’s my hope that this post will make the previous posts easier to find given my recent problems with a blog scraping site. Finding the original content has been difficult in light of my successfully having the scraping site in question remove my content.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=IronPython%20and%20the%20Entity%20Framework%20Part%205.0%20%26ndash%3B%20Concluded&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F02%2F06%2Fironpython-and-the-entity-framework-part-50-concluded%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="IronPython and the Entity Framework Part 5.0 &ndash; Concluded";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/02/06/ironpython-and-the-entity-framework-part-50-concluded/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/02/06/ironpython-and-the-entity-framework-part-50-concluded/">IronPython and the Entity Framework Part 5.0 &ndash; Concluded</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/02/06/ironpython-and-the-entity-framework-part-50-concluded/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ADSD, NServiceBus and Nuclear Armament &#8211; the full story!</title>
		<link>http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/</link>
		<comments>http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 10:49:48 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Courses]]></category>

		<category><![CDATA[Distributed]]></category>

		<category><![CDATA[NServiceBus]]></category>

		<category><![CDATA[SOA]]></category>

		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/</guid>
		<description><![CDATA[After having recently sat through Udi’s 5 day course on Advanced Distributed&#160; Systems Design (ADSD) and after several days of quiet introspection punctuated with some random reconnecting to the web full of it’s opinion and ideas, I found myself ever more at peace with the challenges that lie ahead. During a conversation with Udi whilst [...]<p><a href="http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/">ADSD, NServiceBus and Nuclear Armament &ndash; the full story!</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/nuclear-missile.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="nuclear_missile" border="0" alt="nuclear_missile" align="left" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/02/nuclear-missile-thumb.png" width="133" height="289" /></a>After having recently sat through Udi’s 5 day <a href="http://www.udidahan.com/training/">course</a> on <strong><u>A</u></strong>dvanced <strong><u>D</u></strong>istributed&#160; <strong><u>S</u></strong>ystems <strong><u>D</u></strong>esign (ADSD) and after several days of quiet introspection punctuated with some random reconnecting to the web full of it’s opinion and ideas, I found myself ever more at peace with the challenges that lie ahead. During a conversation with Udi whilst he was here in Melbourne recently, he recalled a <a href="http://twitter.com/markmario/status/6254304647">twitter comment</a> made by my colleague <a href="http://www.markharris.net.au/">Mark</a> wherein he quoted my flippant remark that having NServiceBus at my disposal could be likened to being armed with nuclear weapons. Perhaps it wasn’t the most elegant analogy but I think it conveys the sentiment, I feel able to leverage and harness a great deal energy and power. This sentiment can also be attributed to the many great ideas that you find yourself being exposed to in the ADSD course</p>
<p>In these times of rampant software development technology proliferation, it would be easy to feel overwhelmed and I know from speaking with colleagues that many do, yet somehow I feel more at peace than ever. Technology stacks, frameworks, buzzwords, paradigm shifts, they are all hurtling towards us at a pace most of us have never known and the inertia alone is staggering.</p>
<p>Many of us need help in separating the stuff from the fluff. As Neo said to the architect, “the question is choice”! Well, is it? What are the choices? Do technology choices alone get your system built? No of course they don’t but many have fallen into the trap of behaving as though they do. Ever caught yourself saying something like “oh if I just use MVVM or ASP.NET MVC, my system will be perfect because of benefits X, Y and Z”? Other developers occasionally ask me, “what technology should I learn next” or “how do I future proof myself”? I think they are somewhat surprised by my answer; my advice is to stay as far away as possible from attempting to build value as a <em><strong>vendor stack expert</strong></em> and focus attention on maturing and refining your design and communication skills. It seems obvious really, after all once you have well developed your design and architectural skills, then you are far better placed to make appropriate technology choices. The ensuing&#160; implementation experience will sort out any technology knowledge gaps that you feel the job’s market is causing you to feel downward pressure from. This doesn’t mean ignore technology all together, by all means pull it apart and analyze it, see how it fits but not in isolation – you need to give it it’s context. This became quite plain to me after having been through the course two years ago.</p>
<p>The DDD / SOA course was a lynch pin for me it was the key that has opened many doors. Without the learning in principles first, no technology will stop you from making a mess of things. Again it’s pretty obvious when you say it but I am sure I am not alone as someone who came to the course with a whole set of assumptions based on layered designs and technology fads as a bag of best practice tools and tricks.</p>
<p>I have now had the privilege of sitting this course three times and it never get’s old. Since I first experienced it two years ago, the content has changed a little and become even more refined. Each time I sit through the course I feel more empowered than the last time, the lessons are learned more deeply and start to become part of my psyche. </p>
<p>Some of my fellow <a href="http://rhysc.blogspot.com/2010/01/udi-dahan-advanced-distributed-systems.html">attendees</a> have posted <a href="http://www.paulbatum.com/2010/01/advanced-distributed-systems-design.html">their thoughts</a> upon having completed the course just recently in Melbourne and I suggest you consider their feedback as well. If you haven’t heard there is now a <a href="http://tech.groups.yahoo.com/group/AdvancedDistributedSystemsDesign/">mailing list</a> dedicated to discussing the courses content and if you are planning on attending in London or the US sometime this year you should definitely check out the mailing list.</p>
<p>I would like to leave you with this; if you have not done this course and you have even the vaguest inkling that you might stand to gain something from learning what what some of the best architects in world know but rarely share in great detail, then do whatever it takes to get yourself a seat when next ADSD rolls into town or find a way of bringing Udi and the course to you. </p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=ADSD%2C%20NServiceBus%20and%20Nuclear%20Armament%20%26ndash%3B%20the%20full%20story%21&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F02%2F04%2Fadsd-nservicebus-and-nuclear-armament-the-full-story%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="ADSD, NServiceBus and Nuclear Armament &ndash; the full story!";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/">ADSD, NServiceBus and Nuclear Armament &ndash; the full story!</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/02/04/adsd-nservicebus-and-nuclear-armament-the-full-story/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Why the SOA Guru Web Site SUCKS!</title>
		<link>http://www.simonsegal.net/blog/2010/01/30/why-the-soa-guru-web-site-sucks/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/30/why-the-soa-guru-web-site-sucks/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 08:42:11 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/30/why-the-soa-guru-web-site-sucks/</guid>
		<description><![CDATA[It came to my attention recently that a site called SOA Guru have been scraping my blog and knocking off every single post and publishing under the name of their Admin user. What really annoys me is not that they are earning money off my work but more so that they are taking credit for [...]<p><a href="http://www.simonsegal.net/blog/2010/01/30/why-the-soa-guru-web-site-sucks/">Why the SOA Guru Web Site SUCKS!</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>It came to my attention recently that a site called <a href="www.soaguru.com">SOA Guru</a> have been scraping my blog and knocking off every single post and publishing under the name of their Admin user. What really annoys me is not that they are earning money off my work but more so that they are taking credit for it. If you have a story about this site then please blog it and make sure you report them to Google. I wonder if they will re-blog this post, I hope so.</p>
<p>UPDATE: Their re-post of this post is showing a link back here but it&#8217;s been generated by me to combat the scraping.</p>
<p>UPDATE: After making contact via email I received a response explaining that my material would be removed from their site and that appears to have taken place.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Why%20the%20SOA%20Guru%20Web%20Site%20SUCKS%21&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F30%2Fwhy-the-soa-guru-web-site-sucks%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Why the SOA Guru Web Site SUCKS!";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/30/why-the-soa-guru-web-site-sucks/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/30/why-the-soa-guru-web-site-sucks/">Why the SOA Guru Web Site SUCKS!</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/30/why-the-soa-guru-web-site-sucks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Finding my way with MongoDB and C# &#8211; Part 1.0</title>
		<link>http://www.simonsegal.net/blog/2010/01/26/finding-my-way-with-mongodb-and-c-part-10/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/26/finding-my-way-with-mongodb-and-c-part-10/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 22:40:13 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Distributed]]></category>

		<category><![CDATA[NOSQL]]></category>

		<category><![CDATA[POCO]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/26/finding-my-way-with-mongodb-and-c-part-10/</guid>
		<description><![CDATA[I’m not about to cut all ties with my relational past and abandon the RDBMS. No, indeed that’s not the appropriate response – well at least not at this stage. So an exploration is what is going to be required to help in clarifying whether MongoDB can find a place in my toolbox.
Watching Michael Dirolf [...]<p><a href="http://www.simonsegal.net/blog/2010/01/26/finding-my-way-with-mongodb-and-c-part-10/">Finding my way with MongoDB and C# &ndash; Part 1.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I’m not about to cut all ties with my relational past and abandon the RDBMS. No, indeed that’s not the appropriate response – well at least not at this stage. So an exploration is what is going to be required to help in clarifying whether MongoDB can find a place in my toolbox.</p>
<p>Watching <a href="http://nosql.mypopescu.com/post/288988845/video-michael-dirolf-10gen-introduction-to-mongodb">Michael Dirolf</a> recently sparked my imagination, I began to see a <strong><em>potential</em></strong> abundance of goodness that could be applied in many way – possibly alongside a relational database. The potential for its implementation on the query side in a <a href="http://en.wikipedia.org/wiki/Command-query_separation">CQRS</a> architecture for instance, serving as a store for directly bound <a href="http://www.udidahan.com/2009/12/09/clarified-cqrs/">view model</a> data. MongoDB at first glance offers some nice features that would blend well into an architecture that included serving data from inside the web tier; BSON (binary JSON) may resonate well, it’s unceremonious and lite weight. The future promise of sharding as a product feature also has it’s appeal for obvious reasons. </p>
<h3><u>Figure 1.0 – Potential Architecture</u></h3>
<p>My initial enquiry was grounded in the efficacy of putting MongoDB to work in a distributed <a href="http://en.wikipedia.org/wiki/Publish/subscribe">publish / subscribe</a> architecture where <strong>(N)</strong> subscribing instances of autonomous components in a logical service boundary could effectively update N instances of a dedicated view model database. Each view model perhaps sharing an affinity to a web server allowing scaling out both in tandem. In order to sustain eventual consistency, this architecture employs transactional queues. MongoDB achieves it’s scale efficiencies by ignoring some the properties of an RDBMS that are commonly associated with the difficulties in scaling them. What’s clear is that an architecture that heavily leverages <a href="http://en.wikipedia.org/wiki/Publish/subscribe">publish / subscribe</a>, one way messaging and transactional queues (aimed at providing high availability and scale), will also generally require it’s storage to support transactional behavioural properties. MongoDB advertises it’s replication feature set as part of it’s toolbox, this helps achieve eventual consistency across a shared grid of servers but these two worlds are not about to find a way to play well together. In effect, both seem to be coming to a similar problem with a different solution, with MongoDB addressing scale through it’s built-in auto sharding, focusing more intensely on the database alone. For MongoDB to work in this environment would require the ability to enlist database calls in distributed transactions, something that is not supported by design. It would be possible to add a transactional messaging gateway to solve this problem, however there are other database alternatives that would not require me to take that extra step and additional latency.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image15.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image-thumb13.png" width="425" height="521" /></a> </p>
<p>This of course in <em><strong>no way invalidates</strong></em> assigning value to looking more deeply at MongoDB (and the like), therefore as I plant sign posts along the road about to be travelled and in light of the friction described above, I will now change track somewhat. My next move forward is to get a better grip of what the developer experience is about (not every problem requires the same solution).</p>
<h3><u>Me as Developer - Starting Out</u></h3>
<p>I started out with a somewhat familiar approach, running the JavaScript based shell you can run ad-hoc queries somewhat akin to query analyzer in the SQL Server world. Once installed and having put the binaries in my path environment variable, running the following commands will start up the server and the shell.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> c:\users\simon.segal\mongod</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> c:\users\simon.segal\mongo</pre>
</p></div>
</div>
<h3><u></u></h3>
<h3><u></u></h3>
<h3><u></u></h3>
<h3><u></u></h3>
<p></p>
<h3><u>Figure 2.0 – Mongo Shell &amp; DB</u></h3>
<p></p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image16.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image-thumb14.png" width="260" height="199" /></a></p>
<p>Going from download, to install, to running the shell, inserting and querying for data, is really a relatively quick exercise. With just a dash of reading from the <a href="http://www.mongodb.org/display/DOCS/Developer+Zone">excellent documentation</a> (which also has a friendly readable PDF download utility), you can be writing code in the shell very fast. Code like this doesn’t need a lot of explaining to get going.</p>
<h3><u>Listing 1.0 – Mongo Shell</u></h3>
<p></p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&gt;customer = {firstName: <span style="color: #006080">&quot;Jon&quot;</span>, lastName: <span style="color: #006080">&quot;Doe&quot;</span>, DateJoined: <span style="color: #0000ff">new</span> Date(<span style="color: #006080">&quot;2010/01/30&quot;</span>)};
&gt;db.Customers.save(customer);
&gt;db.Customers.find();
{ <span style="color: #006080">&quot;_id&quot;</span> : ObjectId(<span style="color: #006080">&quot;4b5016e65d3c000000006393&quot;</span>), <span style="color: #006080">&quot;firstName&quot;</span> : <span style="color: #006080">&quot;Jon&quot;</span>, <span style="color: #006080">&quot;lastName&quot;</span>
: <span style="color: #006080">&quot;Doe&quot;</span>, <span style="color: #006080">&quot;DateJoined&quot;</span> : <span style="color: #006080">&quot;Sat Jan 30 2010 00:00:00 GMT+1100 (AUS Eastern Daylight
 Time)&quot;</span> }</pre>
</div>
<div>&#160;</div>
<div>Summarising this code, we create a JSON object in our customer variable, save it to the Customers document collection and create the collection itself in the database with one line of code, then finally query to find all documents in the Customers collection. Doing this from a JavaScript shell is nice but developers all build applications and will therefore preferably be working in their code, whether that’s a Data Access Layer or some kind of a Repository. The answer to this problem is a plethora of language specific drivers that are both created and maintained by <a href="http://www.10gen.com/">10Gen</a> and the community. </div>
<div>&#160;</div>
<h3><u>The Officially Supported Drivers</u></h3>
<ul>
<li>C </li>
<li>C++ </li>
<li>Java </li>
<li>Javascript </li>
<li>Perl </li>
<li>PHP </li>
<li>Python </li>
<li>Ruby </li>
</ul>
<h3><u>The Unofficial Community Supported Drivers</u></h3>
</p>
<ul>
<li>C# </li>
<li>Cold Fusion </li>
<li>Erlang </li>
<li>Factor </li>
<li>Fantom </li>
<li>F# </li>
<li>Go </li>
<li>Groovy </li>
<li>PHP </li>
<li>Powershell </li>
<li>Ruby </li>
</ul>
<h3><u>The C# Driver</u></h3>
<p>You can see that Microsoft technology is fairly well represented in these lists but I want to focus on the C# driver and talk about using MongoDB from C# specifically. Here’s some code using the C# driver to help start getting a feel for the API.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> CreateCustomer()
{
    var mongo = <span style="color: #0000ff">new</span> Mongo(<span style="color: #006080">&quot;127.0.0.1&quot;</span>, <span style="color: #006080">&quot;27017&quot;</span>);
    mongo.Connect();
    var db = mongo.getDB(<span style="color: #006080">&quot;HR&quot;</span>);
    var employees = db.GetCollection(<span style="color: #006080">&quot;Employees&quot;</span>);
    var employee = <span style="color: #0000ff">new</span> Document();
    employee[<span style="color: #006080">&quot;FirstName&quot;</span>] = <span style="color: #006080">&quot;Simon&quot;</span>;
    employee[<span style="color: #006080">&quot;LastName&quot;</span>] = <span style="color: #006080">&quot;Segal&quot;</span>;
    employee[<span style="color: #006080">&quot;JoinDate&quot;</span>] = DateTime.Now;
    employees.Insert(employee);
    var cursor = employees.FindAll();
    <span style="color: #0000ff">foreach</span> (var emp <span style="color: #0000ff">in</span> cursor.Documents)
    {
        Console.WriteLine(<span style="color: #0000ff">string</span>.Format(
            <span style="color: #006080">&quot;Customer ID is {0}, first name is {1} and &quot;</span> +
            <span style="color: #006080">&quot;last name is {2}&quot;</span>, emp[<span style="color: #006080">&quot;_id&quot;</span>],
            emp[<span style="color: #006080">&quot;FirstName&quot;</span>], emp[<span style="color: #006080">&quot;LastName&quot;</span>]));
        Console.WriteLine(emp.ToString());
    }
}</pre>
</div>
<p>After running this code in Visual Studio we get the following output which prints a formatted string and the JSON representation as is.</p>
<h3><u>Figure 1.0</u></h3>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image17.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image-thumb15.png" width="244" height="69" /></a> </p>
</p>
<h3><u>Issues</u></h3>
<p>The first problem with writing code like this is that it’s about as far away from being Domain Driven as I can imagine, there is no concept of an Entity, just a Document. Well it’s a Document Database you say – so why don’t I just stop whining and get on with writing code like that above? Sure transaction script might be great for some scenario’s but when I want to work with a richer domain model I don’t think I should need to change to accommodate the drivers API. Let me be clear, I don’t think there is anything wrong with the API, it’s perfectly fine and in fact I think it’s more than pliable enough for me to use it in other ways that will suit me from time to time. </p>
<p>I alluded earlier in the discussion, to the fact that I originally wanted to proof of concept MongoDB for playing a role as an <strong><em>eventually</em></strong> consistent storage for the Query side of an implementation of <a href="http://en.wikipedia.org/wiki/Command-query_separation">CQRS</a>, where views are being bound directly to view model data (as described <a href="http://www.udidahan.com/2009/12/09/clarified-cqrs/">here</a>) via a RESTFul facade. In part 2.0 I am going to look at how we can build a Context object (think DataContext or ObjectContext) to wrap up the C# driver’s functionality and enable working directly with POCO’s, removing any direct requirement to work from the MongoDB API’s Document class. That’s it for now, let’s see where we end up in Part 2.0.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Finding%20my%20way%20with%20MongoDB%20and%20C%23%20%26ndash%3B%20Part%201.0&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F26%2Ffinding-my-way-with-mongodb-and-c-part-10%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Finding my way with MongoDB and C# &ndash; Part 1.0";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/26/finding-my-way-with-mongodb-and-c-part-10/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/26/finding-my-way-with-mongodb-and-c-part-10/">Finding my way with MongoDB and C# &ndash; Part 1.0</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/26/finding-my-way-with-mongodb-and-c-part-10/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CQRS Presentation by Udi Dahan Recorded in Melbourne</title>
		<link>http://www.simonsegal.net/blog/2010/01/25/cqrs-presentation-by-udi-dahan-recorded-in-melbourne/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/25/cqrs-presentation-by-udi-dahan-recorded-in-melbourne/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 23:57:15 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/25/cqrs-presentation-by-udi-dahan-recorded-in-melbourne/</guid>
		<description><![CDATA[On the 19th of January 2010 Udi Dahan presented on Command Query Responsibility Segregation. The Presentation took place in front of the Victorian .NET User Group. The video jumps around a bit early on but it does settle after a few minutes or so. Also the audio is a bit low in volume and may [...]<p><a href="http://www.simonsegal.net/blog/2010/01/25/cqrs-presentation-by-udi-dahan-recorded-in-melbourne/">CQRS Presentation by Udi Dahan Recorded in Melbourne</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>On the 19th of January 2010 Udi Dahan presented on Command Query Responsibility Segregation. The Presentation took place in front of the <a href="http://www.victoriadotnet.com.au/">Victorian .NET User Group</a>. The video jumps around a bit early on but it does settle after a few minutes or so. Also the audio is a bit low in volume and may need a bit of a boost. Many thanks to <a href="http://www.udidahan.com/">Udi</a> and <a href="http://blogesh.wordpress.com/">Mahesh Krishnan</a> (the User Group Organiser) for making this happen. Watch or download the video <a href="http://www.vimeo.com/8944337">here</a>.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=CQRS%20Presentation%20by%20Udi%20Dahan%20Recorded%20in%20Melbourne&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F25%2Fcqrs-presentation-by-udi-dahan-recorded-in-melbourne%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="CQRS Presentation by Udi Dahan Recorded in Melbourne";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/25/cqrs-presentation-by-udi-dahan-recorded-in-melbourne/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/25/cqrs-presentation-by-udi-dahan-recorded-in-melbourne/">CQRS Presentation by Udi Dahan Recorded in Melbourne</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/25/cqrs-presentation-by-udi-dahan-recorded-in-melbourne/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Why would you want to test your Windows Workflows and WF Services?</title>
		<link>http://www.simonsegal.net/blog/2010/01/16/why-would-you-want-to-test-your-windows-workflows-and-wf-services/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/16/why-would-you-want-to-test-your-windows-workflows-and-wf-services/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 03:58:53 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[NServiceBus]]></category>

		<category><![CDATA[WF]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/16/why-would-you-want-to-test-your-windows-workflows-and-wf-services/</guid>
		<description><![CDATA[ As a an avid NServiceBus admirer my curiosity about the testability of Workflows in .NET 4.0 led me to ask the question in a group setting recently. One of the responses was “why would you want to test a workflow”? The respondent continued with “surely you would only unit test the components leveraged inside [...]<p><a href="http://www.simonsegal.net/blog/2010/01/16/why-would-you-want-to-test-your-windows-workflows-and-wf-services/">Why would you want to test your Windows Workflows and WF Services?</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image14.png"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 5px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image-thumb12.png" border="0" alt="image" width="236" height="198" align="left" /></a> As a an avid <a href="http://www.nservicebus.com/">NServiceBus</a> admirer my curiosity about the testability of Workflows in .NET 4.0 led me to ask the question in a group setting recently. One of the responses was “why would you want to test a workflow”? The respondent continued with “surely you would only unit test the components leveraged inside a workflow”? I have to disagree with this assertion! I do want to test my workflows because of reasons such as:</p>
<ul>
<li>I’d like to know if a given message types and content cause my workflow to behave exactly as I expect.
<ul>
<li>Did my order submission publish a message to any other endpoints interested in the state of the order submissions outcome?</li>
</ul>
</li>
<li>
<div>If the current state of my workflow is about to be de-hydrated, what are my expectations after handling a given message, were the subsequent expected events raised and or messages sent?</div>
</li>
</ul>
<p align="left">These kinds of concerns when dealing with long running processes in my services really do matter – the business requires such co-ordination to work or fail as described by specification and business workflows inherently contain testable logic - think of your average state machine or consider SLA&#8217;s where a de-hydrated (persisted) workflow has passed an acceptable time boundary, raising events commensurate with that business condition. Sure I need to test my business components too but the story is bigger than that!</p>
<p align="left">NServiceBus <a href="http://www.nservicebus.com/Sagas.aspx">Sagas</a> are probably the closest correlation to a workflow in the WF stack and <a href="http://sourceforge.net/apps/mediawiki/nservicebus/index.php?title=Sagas">Sagas</a> are eminently testable with a baked in testing API designed for the purpose. I guess it’s time to check what WF 4.0 has to offer and see what the story is for myself. More on that a bit later.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Why%20would%20you%20want%20to%20test%20your%20Windows%20Workflows%20and%20WF%20Services%3F&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F16%2Fwhy-would-you-want-to-test-your-windows-workflows-and-wf-services%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Why would you want to test your Windows Workflows and WF Services?";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/16/why-would-you-want-to-test-your-windows-workflows-and-wf-services/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/16/why-would-you-want-to-test-your-windows-workflows-and-wf-services/">Why would you want to test your Windows Workflows and WF Services?</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/16/why-would-you-want-to-test-your-windows-workflows-and-wf-services/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Entity Framework, IronPython and PODO&#8217;s &#8211; Can it be done? - Part 4</title>
		<link>http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 09:58:19 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[IronPython]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/</guid>
		<description><![CDATA[We left off with IPY.exe crashing and leaving us a dump file. The code that forced the crash:

orders = ctx.Orders.Where(&#8220;it.CustomerID &#62; &#8216;C&#8217;&#8220;)
for order in Orders:
    print Order.CustomerID
<p><a href="http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/">Entity Framework, IronPython and PODO&rsquo;s &ndash; Can it be done? - Part 4</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>We left off with IPY.exe crashing and leaving us a dump file. The code that forced the crash:</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0a0d06ae-5d79-4c0d-a863-0dc28fa5dbde" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">
<pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #000000;">orders </span><span style="color: #000000;">=</span><span style="color: #000000;"> ctx.Orders.Where(</span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">it.CustomerID &gt; &#8216;C&#8217;</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;">)
</span><span style="color: #0000ff;">for</span><span style="color: #000000;"> order </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> Orders:
    </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> Order.CustomerID</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>I speculated that something other than member assignment (made by the Entity Framework) to string types in the underlying CLR type of the Python entity was failing and you might remember some proof of concept code was demonstrated to show a variety of ways in specifying types to _clrfields and property decorators.</p>
<h3><span style="text-decoration: underline;">The Dump File</span></h3>
<p>So decided to <strong><em>re-watch</em></strong> this timely video presentation by <a href="http://blogs.msdn.com/tess/" target="_blank">Tess Ferrandez</a> and hosted by <a href="http://www.hanselman.com/blog/HanselminutesOn9DebuggingCrashDumpsWithTessFerrandezAndVS2010.aspx" target="_blank">Scott Hanselman</a>, to see if I could get myself up to speed quick enough to debug the crash dump in VS 2010.</p>
<p>Not that it’s relevant to this topic per`se but did find something odd in locating the dump file and thought it’s worth mentioning here: when the system notifies you of a crash that produces a dump file (on Vista 64 in this case), it went through a process of:</p>
<ol>
<li>Prompting with the message that IPY.exe had indeed crashed</li>
<li>Where to find the dump file</li>
</ol>
<p>After noting the path of the dump file and clearing these two dialogs, I went to retrieve the dump file only to find it was not at all where the dialog said it would be. I ran the process again and watch the target folder for the dump file and it appears that when the second dialog is cleared the dump file will be deleted – so make a copy before that happens!</p>
<p>Anyway back to the problem at hand. Once having secured a copy of the crash dump file I loaded into VS.NET 2010 (very slow with downloading the debug symbols for the first time). Eventually this is what I was presented with:</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/ip-crash-dump-summary.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Crash Dump file in Visual Studio - click to see full size" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/ip-crash-dump-summary-thumb.png" border="0" alt="Crash Dump file in Visual Studio - click to see full size" width="244" height="82" /></a></p>
<p>The information of most note here is the exception information:</p>
<blockquote><p>“The thread tried to read from or write to a virtual address for which it does not have the appropriate access”</p></blockquote>
<p><em></em></p>
<p>Obviously it’s important to know what was happening on the active thread when debugging for a system that crashed. When prompted to break by visual studio when all the debug symbols have been loaded I received the following message:</p>
<blockquote><p>An unhandled exception of type &#8216;System.ExecutionEngineException&#8217; occurred in Unknown Module.</p></blockquote>
<p>Not very useful so far huh! When I open the parallel call stacks I can see that eight threads were active at the time of the crash and that execution stopped in NT.DLL and in particular on the call listed below.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/ip-crash-para-call-stacks.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ip_crash_para_call_stacks" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/ip-crash-para-call-stacks-thumb.png" border="0" alt="ip_crash_para_call_stacks" width="244" height="113" /></a></p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">ntdll<span style="color: #cc6633;">.dll</span>!_ZwWaitForSingleObject@12()  + 0&#215;15 bytes</pre>
</div>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/ip-crash-call-stack.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ip_crash_call_stack" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/ip-crash-call-stack-thumb.png" border="0" alt="ip_crash_call_stack" width="464" height="651" /></a></p>
<p>I’m certainly not familiar with debugging dump files but here is what I garnered from the video with Tess. As we look through Call Stack (above) in Visual Studio, we can see that DLR, IronPython and Entity Framework <strong><em>4.0</em></strong> functions were called just prior to the failure however it would seem that debug symbols for all three are not currently available on the Symbol Servers from Microsoft. I haven’t yet been able to find them nor been able to locate the source for the special IronPython 2.6 Beta Version for .NET framework 4.0. So we appear to be at impasse, I will continue to see if I can get any deeper into the why and wherefore of the crash and hope to find that one day Plain Old DLR Objects (PODO’s) and Entity Framework can play together in harmony.</p>
<h3><span style="text-decoration: underline;">Conclusion</span></h3>
<p>It this point in time I would certainly say that using Entity Framework with IronPython will require you build a managed wrapper class(es) that roll up what you want from the entity framework. I showed this to some extent previously with IronRuby in these <a href="http://www.simonsegal.net/blog/2009/02/08/ironruby-and-the-entity-framework-part-1/">two</a> <a href="http://www.simonsegal.net/blog/2009/03/11/ironruby-and-the-entity-framework-part-2/">posts</a>. Perhaps with a bit of collaborative work the DLR and ADO.NET teams can do a mind meld and move that bit close to making the DLR languages have a more compelling story in this endeavour, however I suppose the question should be asked, is this kind of interop that they have in mind for the dynamic languages?</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Entity%20Framework%2C%20IronPython%20and%20PODO%26rsquo%3Bs%20%26ndash%3B%20Can%20it%20be%20done%3F%20-%20Part%204&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F14%2Fentity-framework-ironpython-and-podos-can-it-be-done-part-4%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Entity Framework, IronPython and PODO&rsquo;s &ndash; Can it be done? - Part 4";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/">Entity Framework, IronPython and PODO&rsquo;s &ndash; Can it be done? - Part 4</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/14/entity-framework-ironpython-and-podos-can-it-be-done-part-4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Entity Framework, IronPython and PODO&#8217;s &#8211; Can it be done? - Part 3</title>
		<link>http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 23:17:33 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[IronPython]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/</guid>
		<description><![CDATA[Before we dive into proxies when using POCO in the Entity Framework lets have a quick recap on where we left off in part 2.0.

Entity Framework will load PODO’s (plain old DLR Objects) fine as long as:

No primitives other than strings are used for fields and properties


Eager Loading works when ObjectQuery[T].Include() is used.

TSQL profiling confirms [...]<p><a href="http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/">Entity Framework, IronPython and PODO&rsquo;s &ndash; Can it be done? - Part 3</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Before we dive into proxies when using POCO in the Entity Framework lets have a quick recap on where we left off in part 2.0.</p>
<ul>
<li>Entity Framework will load PODO’s (plain old DLR Objects) fine as long as:
<ul>
<li>No primitives other than strings are used for fields and properties</li>
</ul>
</li>
<li>Eager Loading works when ObjectQuery[T].Include() is used.
<ul>
<li>TSQL profiling confirms this.</li>
</ul>
</li>
<li>Lazy Loading does not appear to work at all</li>
<li>Type names of materialized entities are not what are expected for runtime generated proxies.</li>
</ul>
<p>Let’s talk about proxies a little. I wont delve too deep only enough that’s relevant to the problem at hand. Entity Framework creates proxies at runtime for our POCO entities, essentially so the framework can know the entities a vice versa, they maintain the glue so to speak. The glue is there to enable lazy loading and change tracking specifically. If you want to know more about proxies I suggest reading this <a href="http://blogs.msdn.com/adonet/archive/2009/12/22/poco-proxies-part-1.aspx" target="_blank">post</a> from the ADO.Net team blog. Figure 1.0 depicts debug data of a materialized proxy Entity in a C# library. Notice the unusual name of the proxy Entity in the watch window in figure 1.0 – the Entity Framework generates proxy types in the System.Data.Entity.DynamicProxies namespace.</p>
<h3><span style="text-decoration: underline;">Figure 1.0</span></h3>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/podos-part3-proxy-vs2010.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="podos_part3_proxy_vs2010" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/podos-part3-proxy-vs2010-thumb.png" border="0" alt="podos_part3_proxy_vs2010" width="450" height="374" /></a></p>
<p>At this point, we know we are not seeing proxy type names come back when we ask our PODO for it’s full name and we are not getting any love from Lazy Loading at all. Our materialized Entities are indeed the type as engineered via __clrtype__ and we saw this when querying for the namespace of the Entity from IronPython in part 2.0.</p>
<p>In a nutshell, the Entity Framework is querying the database and materializing our PODO’s, however given the circumstances its reasonable to argue that no proxying is taking place and hence no lazy loading. Let’s put that theory to the test just a little more shall we! When proxies are employed in the Entity Framework there are two basic usages; proxies that support either Lazy Loading only or Change Tracking with Lazy Loading, the latter option requires all mapped properties be declared virtual and be public or protected. In Python class properties, functions and methods are considered to be as good as virtual, so we will just assume for the moment that this clears the way for the Entity Framework to work with our PODO’s as any other normal compliant class that is <strong><em>proxyable</em></strong> (of course there is no such word).</p>
<p>Since we are getting no proxy generation with our PODO’s then we would equally expect change tracking to fail would we not? Note in figure 1.0 that a (C#) proxy when examined has a reference to the Entity Tracker and other Entity Framework plumbing required to manage it, which we would expect to be missing if our theory about what’s happening to our PODO’s is correct. Let’s now put the whole proxy and change tracking question to rest.</p>
<div id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8da59957-16d4-4371-8ce7-a840915fa418" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">
<pre style="background-color:#FFFFFF;overflow: auto;"><span style="color: #0000ff;">def</span><span style="color: #000000;"> IsProxy(theType):
    ctxType </span><span style="color: #000000;">=</span><span style="color: #000000;"> ObjectContext.GetObjectType(theType.GetType())
    notNull </span><span style="color: #000000;">=</span><span style="color: #000000;"> theType </span><span style="color: #000000;">!=</span><span style="color: #000000;"> None
    isCtxObj </span><span style="color: #000000;">=</span><span style="color: #000000;"> ctxType </span><span style="color: #000000;">!=</span><span style="color: #000000;"> theType.GetType();
    </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">\tThis entity is a %(podo)s</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;"> \
                </span><span style="color: #000000;">%</span><span style="color: #000000;">{</span><span style="color: #800000;">&#8216;</span><span style="color: #800000;">podo</span><span style="color: #800000;">&#8216;</span><span style="color: #000000;">:theType.GetType()}
    </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">\tIt&#8217;s type in the ObjectContext is %(ctxType)s</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;"> \
                </span><span style="color: #000000;">%</span><span style="color: #000000;">{</span><span style="color: #800000;">&#8216;</span><span style="color: #800000;">ctxType</span><span style="color: #800000;">&#8216;</span><span style="color: #000000;">:ctxType}
    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> notNull </span><span style="color: #0000ff;">and</span><span style="color: #000000;"> isCtxObj

</span><span style="color: #0000ff;">def</span><span style="color: #000000;"> IsChangeTracking(podo):
    state </span><span style="color: #000000;">=</span><span style="color: #000000;"> ctx.ObjectStateManager.GetObjectStateEntry(podo).State
    </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">\tIt&#8217;s state is: %(state)s</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;"> </span><span style="color: #000000;">%</span><span style="color: #000000;"> {</span><span style="color: #800000;">&#8216;</span><span style="color: #800000;">state</span><span style="color: #800000;">&#8216;</span><span style="color: #000000;">:state}
    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> state </span><span style="color: #000000;">==</span><span style="color: #000000;"> System.Data.EntityState.Modified

ctx.ProxyCreationEnabled  </span><span style="color: #000000;">=</span><span style="color: #000000;"> True

parents </span><span style="color: #000000;">=</span><span style="color: #000000;"> ctx.ParentRecords\
             .Where(</span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">it.ParentID != &#8216;bob&#8217;</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;">)\
             .Include(</span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">ChildRecords</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;">)

</span><span style="color: #0000ff;">for</span><span style="color: #000000;"> parent </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> parents:
    </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> parent.ParentID
    parent.ParentName </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">change tracking works nonetheless</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;">
    isProxy </span><span style="color: #000000;">=</span><span style="color: #000000;"> IsProxy(parent).ToString()
    isChange </span><span style="color: #000000;">=</span><span style="color: #000000;"> IsChangeTracking(parent).ToString()
    </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">\tIt is %(proxy)s that this PODO is a proxy</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;"> \
                </span><span style="color: #000000;">%</span><span style="color: #000000;">{</span><span style="color: #800000;">&#8216;</span><span style="color: #800000;">proxy</span><span style="color: #800000;">&#8216;</span><span style="color: #000000;">:isProxy}
    </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">\tIt is %(change)s that this PODO supports </span><span style="color: #800000;">&#8220;</span><span style="color: #000000;"> \
                </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">proxy style change tracking</span><span style="color: #800000;">&#8220;</span><span style="color: #000000;"> </span><span style="color: #000000;">%</span><span style="color: #000000;">{</span><span style="color: #800000;">&#8216;</span><span style="color: #800000;">change</span><span style="color: #800000;">&#8216;</span><span style="color: #000000;">:isChange}
    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> parent.ChildRecords </span><span style="color: #000000;">!=</span><span style="color: #000000;"> None:
        </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> child </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> parent.ChildRecords:
            </span><span style="color: #0000ff;">print</span><span style="color: #000000;"> </span><span style="color: #800000;">&#8220;</span><span style="color: #800000;">\t\tChildID is : </span><span style="color: #800000;">&#8220;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> child.ChildID

ctx.SaveChanges()</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></p>
</div>
<p>We have added two methods, one to check if an Entity is a proxy and another to verify if change tracking is working via our proxy. Running this code produces the following TSQL, subsequent changes to the database and debug window output in NetBeans.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff;">exec</span> sp_executesql N<span style="color: #006080;">&#8216;update [dbo].[ParentRecords]
set [ParentName] = @0
where ([ParentID] = @1)
&#8216;</span>,N<span style="color: #006080;">&#8216;@0 nvarchar(50),@1 char(5)&#8217;</span>,@0=N<span style="color: #006080;">&#8216;change tracking&#8217;</span>,@1=<span style="color: #006080;">&#8216;FGHIJ&#8217;</span></pre>
</div>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/podos-part3-change-track-ok.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="podos_part3_change_track_ok" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/podos-part3-change-track-ok-thumb.png" border="0" alt="podos_part3_change_track_ok" width="400" height="92" /></a></p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image12.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image-thumb10.png" border="0" alt="image" width="260" height="131" /></a></p>
<p>An interesting set of results. As suspected we have no proxies with Lazy Loading or Change tracking ability but we do have change tracking nonetheless when we get a diff from the ObjectContext. The call to .SaveChanges() on the ObjectContext is still persisting the change to the database regardless of the absence of the proxy creation.</p>
<p>To summarise, we now have established that loading data into PODO’s works despite producing no proxy. We can eager load only and we still have the rather large problem with natives that are not strings; this still leaves us with the little problem of this ugly message.</p>
<p><a href="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image13.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.simonsegal.net/blog/wp-content/uploads/2010/01/image-thumb11.png" border="0" alt="image" width="417" height="219" /></a></p>
<p>One thing that I meant to mention in one of the earlier posts is that clrtype.py does not support the use of iterables and IronPython classes in the @Accepts and @Returns decorators out of the box. Thanks to help given by <a href="http://twitter.com/cendalc">Lukas Cenovsky</a> on the IronPython <a href="http://groups.google.com/group/ironpy/browse_thread/thread/ce53afbeeba5d694?pli=1" target="_blank">mailing list</a> who made the required changes to the <strong><em>validate_clr_types</em></strong> method in <a href="http://ironpython.net/ironpython/documentation/dotnet/dotnet.html#clrtype">clrtype.py</a> to get over this hurdle.</p>
<p>So now it’s time I thought to jump into VS 2010 and see what we can discover by checking out the dump file created by the IPY.exe crash. And that is where part 4.0 of the series will start. Until then.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Entity%20Framework%2C%20IronPython%20and%20PODO%26rsquo%3Bs%20%26ndash%3B%20Can%20it%20be%20done%3F%20-%20Part%203&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F13%2Fentity-framework-ironpython-and-podos-can-it-be-done-part-3%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Entity Framework, IronPython and PODO&rsquo;s &ndash; Can it be done? - Part 3";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/">Entity Framework, IronPython and PODO&rsquo;s &ndash; Can it be done? - Part 3</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/13/entity-framework-ironpython-and-podos-can-it-be-done-part-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Udi Dahan to present at Victoria DNUG on 19th January &#8211; CQRS</title>
		<link>http://www.simonsegal.net/blog/2010/01/12/udi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/12/udi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 15:22:21 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/12/udi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs/</guid>
		<description><![CDATA[Udi Dahan (aka the Software Simplist and original author of NServiceBus) will be presenting to the Victoria.Net User Group on the 19th of January in the Melbourne CBD at Innovation@257, Collins St. The evening begins at 5:30 PM with pizza and drinks and presentations begin at 6:00 PM. Visit this link and register with an [...]<p><a href="http://www.simonsegal.net/blog/2010/01/12/udi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs/">Udi Dahan to present at Victoria DNUG on 19th January &ndash; CQRS</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Udi Dahan (aka the <a href="http://www.udidahan.com/" target="_blank">Software Simplist</a> and original author of <a href="http://www.nservicebus.com/" target="_blank">NServiceBus</a>) will be presenting to the <a href="http://www.victoriadotnet.com.au/vic_index.aspx">Victoria.Net User Group</a> on the 19th of January in the Melbourne CBD at Innovation@257, Collins St. The evening begins at 5:30 PM with pizza and drinks and presentations begin at 6:00 PM. Visit this link and register with an RSVP as detailed:</p>
<p><a title="RSVP" href="http://www.victoriadotnet.com.au/vic-events/vic-technical-events.aspx" target="_blank">REGISTER HERE</a></p>
<p>If you haven’t come across Command Query Responsibility Segregation (CQRS) before, you can catch up and do some background reading on Udi’s blog at the following spots.</p>
<p><a href="http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/" target="_blank">Command Query Separation and SOA</a></p>
<p><a href="http://www.udidahan.com/2009/12/09/clarified-cqrs/" target="_blank">Clarified CQRS</a></p>
<p>Look forward to seeing a big turn out for this rare opportunity to see Udi present here is Australia.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Udi%20Dahan%20to%20present%20at%20Victoria%20DNUG%20on%2019th%20January%20%26ndash%3B%20CQRS&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F12%2Fudi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Udi Dahan to present at Victoria DNUG on 19th January &ndash; CQRS";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/12/udi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/12/udi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs/">Udi Dahan to present at Victoria DNUG on 19th January &ndash; CQRS</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/12/udi-dahan-to-present-at-victoria-dnug-on-19th-january-cqrs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Entity Framework &#8211; Repositories, Fetching Strategies, Specification and Mapping &#8211; Using NFetchSpec for Role Driven Development. Parts 1 - 4</title>
		<link>http://www.simonsegal.net/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4/</link>
		<comments>http://www.simonsegal.net/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 22:08:23 +0000</pubDate>
		<dc:creator>Simon Segal</dc:creator>
		
		<category><![CDATA[DDD]]></category>

		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[ORM]]></category>

		<category><![CDATA[POCO]]></category>

		<guid isPermaLink="false">http://www.simonsegal.net/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4/</guid>
		<description><![CDATA[Over the course of the next month or so I will be posting a series on using a set of helper libraries which I refer to as NFetchSpec. I have taken the somewhat unusual course of creating this dedicated post that will act as an index of sorts for this series. Another reason for this [...]<p><a href="http://www.simonsegal.net/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4/">Entity Framework &ndash; Repositories, Fetching Strategies, Specification and Mapping &ndash; Using NFetchSpec for Role Driven Development. Parts 1 - 4</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Over the course of the next month or so I will be posting a series on using a set of helper libraries which I refer to as NFetchSpec. I have taken the somewhat unusual course of creating this dedicated post that will act as an index of sorts for this series. Another reason for this aggregated index page is that the title of the series accurately reflects the intent of its content however not so much in a search friendly way and I want to make sure that it can be easily found by people who are interested in using Repositories, Fetching Strategies, Specifications and code only mapping.</p>
<p>NFetchSpec aims to provide a basis for using Repositories, Fetching Strategies, Specifications and Code Only mapping using a Role Driven methodology. Here is some example consumer code of NFetchSpec:</p>
<h3><span style="text-decoration: underline;">Listing 1.0</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var customersStartWithA =
    <span style="color: #0000ff;">new</span> Specification&lt;IMakeCustomerPrefered&gt;
        (c =&gt; c.CompanyName.StartsWith(&#8221;A&#8221;));

var <span style="color: #0000ff;">fetch</span> = <span style="color: #0000ff;">new</span> FetchingStrategy&lt;IMakeCustomerPrefered&gt;(<span style="color: #0000ff;">true</span>);

<span style="color: #0000ff;">fetch</span>.AddIntentions(<span style="color: #0000ff;">new</span> IEagerFetchingIntention[]
{
    EagerFetchingIntention.CreateInstance&lt;IMakeCustomerPrefered,
                                          ICollection&lt;IOrder&gt;&gt;(c =&gt; c.Orders)
});

var repo = <span style="color: #0000ff;">new</span> CustomerBuyingStatusRepository();

var custs =
    repo.<span style="color: #0000ff;">Get</span>&lt;IMakeCustomerPrefered&gt;(customersStartWithA, <span style="color: #0000ff;">fetch</span>);

foreach (var cust <span style="color: #0000ff;">in</span> custs)
{
    cust.MakePrefered();
}</pre>
</div>
<p>As described in <a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/" target="_blank">Part 1.0</a>, a role is an interface that describes a business or system event and can flag our  intention; in the case of the code above, the intention is to make the Customer Preferred. Using NFetchSpec, this style of working (using roles) seeps into all aspects of the code. This is certainly not a requirement to use NFetchSpec and I will give some examples to the contrary as we get deeper into the series of posts, but it is the key reason for developing it. In Listing 1.0 we are using NFetchSpec to create a search predicate using a Specification instance, a Fetching Strategy to determine the most appropriate loading for the role and then finally using the Repository to get a Customer to make preferred. The API of NFetchSpec supports writing code like this, where each of the moving parts can be written in line together, however as mentioned in <a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/" target="_blank">Part 1.0</a>, one of the benefits of working in this role driven way is that we can use some IoC techniques to discover the correct Specifications and Fetching Strategies based on their implementing a given role, i.e, the interface that is specified to the Repositories .Get&lt;TRole&gt;() method. This is closer to the intended proposed usage:</p>
<h3><span style="text-decoration: underline;">Listing 2.0</span></h3>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var repo = <span style="color: #0000ff;">new</span> CustomerBuyingStatusRepository();

var custs =
    repo.<span style="color: #0000ff;">Get</span>&lt;IMakeCustomerPrefered&gt;();</pre>
</div>
<p>The Code here in Listing 2.0 will instruct the NFetchSpec infrastructure to find a fetching strategy and Specification for this role when the overloaded version of the .Get&lt;TRole&gt;() method is called. This approach makes for an extremely flexible approach, swapping out the most appropriate component – if I don’t like the fetching strategy for a given role, I can simply replace it, facilitating just in time performance tuning (in the case of fetching) as we observe the system over time.</p>
<p>Here are the links to the posts in the series. You might notice that some of the links are not complete meaning that that post is yet to come. I will update this list as new posts make there way out.</p>
<p><a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/" target="_blank">Helping the Entity Framework Play it&#8217;s &lt;Role&gt; Part 1.0</a> (posted)</p>
<p><a href="http://www.simonsegal.net/blog/2010/02/17/helping-entity-framework-v40-play-its-role-part-20/">Helping the Entity Framework Play it&#8217;s &lt;Role&gt; Part 2.0</a> (posted)</p>
<p><a href="http://www.simonsegal.net/blog/2010/02/21/helping-entity-framework-v40-play-its-role-part-30/" target="_blank">Helping the Entity Framework Play it&#8217;s &lt;Role&gt; Part 3.0</a> (posted)</p>
<p><a href="http://www.simonsegal.net/blog/2010/03/15/helping-entity-framework-v40-play-its-role-part-40/" target="_blank">Helping the Entity Framework Play it&#8217;s &lt;Role&gt; Part 4.0</a> (posted)</p>
<p>All the code will be available on conclusion with the final post. Just one small thing before signing off, I really want to <a href="http://www.simonsegal.net/blog/2010/01/04/helping-entity-framework-v40-play-its-role-part-10/" target="_blank">re-emphasise</a> that it’s a really good idea to <a href="http://www.infoq.com/presentations/Making-Roles-Explicit-Udi-Dahan" target="_blank">watch Udi</a> present the ideas that lead me to attempt accommodating this approach for Entity Framework.</p>
<p class="addtoany_share_save">
    <a name="a2a_dd" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/bookmark?sitename=Living%20in%20the%20Tech%20Avalanche%20Generation&amp;siteurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F&amp;linkname=Entity%20Framework%20%26ndash%3B%20Repositories%2C%20Fetching%20Strategies%2C%20Specification%20and%20Mapping%20%26ndash%3B%20Using%20NFetchSpec%20for%20Role%20Driven%20Development.%20Parts%201%20-%204&amp;linkurl=http%3A%2F%2Fwww.simonsegal.net%2Fblog%2F2010%2F01%2F11%2Fentity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4%2F"><img src="http://www.simonsegal.net/blog/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Entity Framework &ndash; Repositories, Fetching Strategies, Specification and Mapping &ndash; Using NFetchSpec for Role Driven Development. Parts 1 - 4";
		a2a_linkurl="http://www.simonsegal.net/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4/";
				a2a_show_title=1;    </script>
    <script type="text/javascript" src="http://www.addtoany.com/menu/page.js"></script>

	</p><p><a href="http://www.simonsegal.net/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4/">Entity Framework &ndash; Repositories, Fetching Strategies, Specification and Mapping &ndash; Using NFetchSpec for Role Driven Development. Parts 1 - 4</a> is a post from: <a href="http://www.simonsegal.net/blog">Living in the Tech Avalanche Generation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonsegal.net/blog/2010/01/11/entity-framework-repositories-fetching-strategies-specification-and-mapping-using-nfetchspec-for-role-driven-development-parts-1-4/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.920 seconds -->
<!-- Cached page served by WP-Cache -->
