<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"><channel><title>BloggingAbout.NET</title><link>http://bloggingabout.net/blogs/</link><description>Thoughts of developers</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Documents.Open returns null, running Word automation under ASP.NET on x64</title><link>http://bloggingabout.net/blogs/rick/archive/2012/02/02/documents-open-returns-null-when-running-under-asp-net-on-an-64-bit-machine.aspx</link><pubDate>Thu, 02 Feb 2012 04:53:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577121</guid><dc:creator>Rick van den Bosch</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;When building an ASPapplication that generates Word documents,&amp;nbsp; it was working fine on&amp;nbsp;the local machine. A&amp;nbsp;windows XP installation with Office 2007.&amp;nbsp;When we&amp;nbsp;deployed it to windows 2008 (64 bit) and Word 2007 we saw that&amp;nbsp;Documents.Open returned null.&amp;nbsp;Other than this, there are no exceptions.&lt;/p&gt;
&lt;p&gt;The code that returned the error (simplified):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new,courier;"&gt;Application app = new Application();&lt;br /&gt;Document doc = app.Documents.Open(ref name);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As it turns out, a 64 bit system stores temporary files in &amp;quot;C:\Windows\SysWOW64\config\systemprofile\Desktop&amp;quot; folder.&amp;nbsp;&lt;strong&gt;&lt;em&gt;The solution&lt;/em&gt;&lt;/strong&gt;: create a new directory called &amp;quot;Desktop&amp;quot; inside&amp;nbsp;&amp;quot;C:\Windows\SysWOW64\config\systemprofile\&amp;quot;&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577121" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/rick/archive/tags/.Net/default.aspx">.Net</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/HowTo/default.aspx">HowTo</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/Error/default.aspx">Error</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/Development/default.aspx">Development</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/automation/default.aspx">automation</category></item><item><title>Tech to try in 2012 </title><link>http://bloggingabout.net/blogs/mischa/archive/2012/02/01/tech-to-try-in-2012.aspx</link><pubDate>Tue, 31 Jan 2012 23:10:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577181</guid><dc:creator>Mischa Kroon</dc:creator><slash:comments>0</slash:comments><description>February is already here and I&amp;#39;ve been meaning to write this for quite a while. This year I want to have tried some new tech by the end of the year, it&amp;#39;s very common for me to want to try different technologies but a little less common that I actually give myself a goal with a deadline. So I guess this will be the first time. The tech I want to have tried: Monogame : I want to have made a game with this, not sure on which platforms I want to be able to run it yet. So what tech do you think...(&lt;a href="http://bloggingabout.net/blogs/mischa/archive/2012/02/01/tech-to-try-in-2012.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577181" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/mischa/archive/tags/Things+to+try/default.aspx">Things to try</category></item><item><title>nServiceBus synchronously</title><link>http://bloggingabout.net/blogs/dennis/archive/2012/01/31/nservicebus-synchronously.aspx</link><pubDate>Tue, 31 Jan 2012 15:03:17 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577180</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;When you read a title like this, everything that makes you a developer should start worrying. Because nServiceBus is build on top of the concept of asynchronous messaging. Normally, it does not support the request/reply communication pattern as you would normally understand this pattern. You are able to send a reply message to the originator, the application that initially sent you the message. But this is inherently asynchronous.&lt;/p&gt;  &lt;p&gt;However… With the company I work for, we’re investing a lot of time on messaging. One application needed to call a component that supported this asynchronous messaging. The application itself however is very linear and was very, very hard to interrupt, send a message and have a message handler wait for the result. This really required a Saga and this was too much work at the time. We already had plans for a refactoring where we’d introduce a Saga, but we needed the functionality that called out this other component now. So we created a small piece of code that actually waits for nServiceBus te receive the reply. After this the normal flow of the application can continue.&lt;/p&gt;  &lt;p&gt;Again, I really need to clarify that this was a temporary solution and eventually we fixed this by refactoring the code and support a Saga, a long running process that was persisted while waiting for the response.&lt;/p&gt;  &lt;p&gt;Here’s the code to do it though&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;DataResponseMessage response = null;

RequestDataMessage message = new RequestDataMessage() { DataId = g, SomeMessage = &amp;quot;Whatever&amp;quot; };

var synchronousHandle = Bus.Send(message)
                            .Register(asyncResult =&amp;gt;
                            {
                                NServiceBus.CompletionResult completionResult = asyncResult.AsyncState as NServiceBus.CompletionResult;
                                if (completionResult != null &amp;amp;&amp;amp; completionResult.Messages.Length &amp;gt; 0)
                                {
                                    // Always expecting one IMessage as reply
                                    response = completionResult.Messages[0] as DataResponseMessage;
                                }
                            }
                            , null);

synchronousHandle.AsyncWaitHandle.WaitOne();

Console.WriteLine(&amp;quot;Reply : {0}&amp;quot;, response.ResponseMessage);&lt;/pre&gt;

&lt;p&gt;For completeness, I’ll include the message handler from the component the message was sent to. This is normal nServiceBus code.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class RequestDataMessageHandler : IHandleMessages&amp;lt;RequestDataMessage&amp;gt;
{
    public IBus Bus { get; set; }

    public void Handle(RequestDataMessage message)
    {
        var response = Bus.CreateInstance&amp;lt;DataResponseMessage&amp;gt;(m =&amp;gt; 
        { 
            m.DataId = message.DataId;
            m.ResponseMessage = &amp;quot;I got the message : &amp;quot; + message.SomeMessage;
        });

        Bus.Reply(response);
    }
}&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577180" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Architecture+and+Design/default.aspx">Architecture and Design</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/nServiceBus/default.aspx">nServiceBus</category></item><item><title>Unhandled exception installing SQL Server 2008 R2 on a Windows XP machine</title><link>http://bloggingabout.net/blogs/rick/archive/2012/01/27/unhandled-exception-installing-sql-server-2008-r2-in-a-windows-xp-machine.aspx</link><pubDate>Fri, 27 Jan 2012 04:46:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577167</guid><dc:creator>Rick van den Bosch</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/rick/7633.SQL2008r2_5F00_installerror.png"&gt;&lt;img width="300" src="http://bloggingabout.net/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/rick/7633.SQL2008r2_5F00_installerror.png" alt="System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for userSettings/Microsoft.SqlServer.Configuration.LandingPage.Properties.Settings: Could not load file or assembly &amp;#39;System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&amp;#39; or one of its dependencies. The system cannot find the file specified. (C:\Documents and Settings\BoschR\Local Settings\Application Data\Microsoft_Corporation\LandingPage.exe_StrongName_ryspccglaxmt4nhllj5z3thycltsvyyx\10.0.0.0\user.config line 5) ---&amp;gt; System.IO.FileNotFoundException: Could not load file or assembly &amp;#39;System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&amp;#39; or one of its dependencies. The system cannot find the file specified." border="0" style="BORDER-BOTTOM:0px;BORDER-LEFT:0px;FLOAT:right;BORDER-TOP:0px;BORDER-RIGHT:0px;" /&gt;&lt;/a&gt;When installing SQL Server 2008 R2 on a Windows XP development machine that has been around for quite some time, I got an error stating an unhandled exception occured in the application (see image). The error showed up directly upon startup and read:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;An error occurred creating the configuration section handler for userSettings/Microsoft.SqlServer.Configuration.LandingPage.Properties.Settings: Could not load file or assembly &amp;#39;System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&amp;#39; or one of its dependencies.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Repairing&amp;nbsp;the .NET 4.0 framework didn&amp;#39;t solve the issue. Neither did removing&amp;nbsp;all SQL stuff through &amp;#39;Add or Remove Programs&amp;#39;.&amp;nbsp;Looking into the error a bit further...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;em&gt;The system cannot find the file specified. (C:\Documents and Settings\_USERNAME_\Local Settings\Application Data\Microsoft_Corporation\LandingPage.exe_StrongName_ryspccglaxmt4nhllj5z3thycltsvyyx\10.0.0.0\user.config line 5) ---&amp;gt; System.IO.FileNotFoundException: Could not load file or assembly &amp;#39;System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&amp;#39; or one of its dependencies. The system cannot find the file specified.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;So the problem probably&amp;nbsp;wasn&amp;#39;t that System.dll couldn&amp;#39;t be found, but some user.config file for the landingpage executable. The solution is as simple as it is radical: remove the entire (temporary) folder &amp;#39;C:\Documents and Settings\_USERNAME_\Local Settings\Application Data\Microsoft_Corporation&amp;#39; (where USERNAME_ is, of course, the current username). After this the setup should start up without any problems.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577167" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/rick/archive/tags/.Net/default.aspx">.Net</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/Work/default.aspx">Work</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/Error/default.aspx">Error</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/Development/default.aspx">Development</category><category domain="http://bloggingabout.net/blogs/rick/archive/tags/SQL/default.aspx">SQL</category></item><item><title>Introducing Simple.Data OData provider</title><link>http://bloggingabout.net/blogs/vagif/archive/2011/12/29/introducing-simple-data-odata-provider.aspx</link><pubDate>Thu, 29 Dec 2011 21:12:36 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577087</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Mark Rendle’s &lt;a href="https://github.com/markrendle/Simple.Data"&gt;Simple.Data&lt;/a&gt; has quickly become a popular choice to retrieve data from various data sources. The number of Simple.Data providers includes today SQL Server, Oracle, Mysql, MongoDB and others. When I saw Simple.Data in action, I became enthusiastic about extending its list of providers with OData. I believe dynamic nature of Simple.Data matches very well RESTful nature of OData. Currently Visual Studio offers creation of a client context from an OData feed using “Add Service Reference” dialog which treats an OData service like it was a traditional SOAP service. This is unfortunate because OData communication does not need an interface proxy: communication is based on HTTP methods and can be implemented without context creation ceremony.&lt;/p&gt;  &lt;p&gt;Welcome to Simple.Data OData provider! When I asked Mark Rendle on Twitter if he had thought about writing a Simple.Data OData provider, he replied that he was working on Windows Azure table provider that also uses OData protocol, and he offered me to join the project and focus on generic OData client implementation. This gave me an exciting opportunity, and today I am glad to announce that Simple.Data OData provider preview is available, and it’s &lt;a href="https://www.nuget.org/packages/Simple.Data.OData"&gt;Nuget feed is published&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Simple.Data OData provider is &lt;a href="https://github.com/simplefx/Simple.OData"&gt;hosted at GitHub&lt;/a&gt;. The source code based is shared by OData and Azure provider implementation, but the Nuget packages are different.&lt;/p&gt;  &lt;h3&gt;Getting started with Simple.Data OData provider&lt;/h3&gt;  &lt;p&gt;The easiest way to start using Simple.Data OData provider is to install it’s Nuget package. In Visual Studio open Package Manager console and type the following:&lt;/p&gt;  &lt;pre&gt;Install-Package Simple.Data.OData&lt;/pre&gt;

&lt;p&gt;You will see output similar to this:&lt;/p&gt;

&lt;pre&gt;Attempting to resolve dependency &amp;#39;Simple.Data.Core (≥ 0.12.2.2)&amp;#39;.
Successfully installed &amp;#39;Simple.Data.OData 0.1.1&amp;#39;.
Successfully added &amp;#39;Simple.Data.OData 0.1.1&amp;#39; to SimpleODataTest.&lt;/pre&gt;

&lt;p&gt;In the source file where you will be using OData provider import namespaces:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;using Simple.Data; 
using Simple.Data.OData;&lt;/pre&gt;

&lt;p&gt;Create an instance of dynamic database object that will be used to communication with OData feed:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;dynamic db = Database.Opener.Open(&amp;quot;&lt;a href="http://packages.nuget.org/v1/FeedService.svc/"&gt;http://packages.nuget.org/v1/FeedService.svc/&lt;/a&gt;&amp;quot;);&lt;/pre&gt;

&lt;p&gt;Now you can start retrieving data from the OData server using Simple.Data syntax:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;var package = db.Packages.FindByTitle(&amp;quot;Simple.Data.OData&amp;quot;); 
Console.WriteLine(package.Title);&lt;/pre&gt;

&lt;h3&gt;Reading data using Simple.Data OData provider&lt;/h3&gt;

&lt;pre class="brush: csharp;"&gt;package = db.Packages.FindByTitleAndVersion(&amp;quot;Simple.Data.OData&amp;quot;, &amp;quot;0.1.1.2&amp;quot;);
Console.WriteLine(package.Title);&lt;/pre&gt;

&lt;p&gt;Find multiple results:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;IEnumerable&amp;lt;dynamic&amp;gt; packages = db.Packages.FindAllByTitle(&amp;quot;Simple.Data.OData&amp;quot;);
packages.ToList().ForEach(x =&amp;gt; Console.WriteLine(x.Title + &amp;quot; &amp;quot; + x.Version));

packages = db.Packages.FindAll(db.Packages.Version == &amp;quot;1.0.0.0&amp;quot;);
packages.ToList().ForEach(x =&amp;gt; Console.WriteLine(x.Title + &amp;quot; &amp;quot; + x.Version));&lt;/pre&gt;

&lt;p&gt;Select column subset:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;IEnumerable&amp;lt;dynamic&amp;gt; packages = db.Packages
    .FindAllByTitle(&amp;quot;Simple.Data.OData&amp;quot;)
    .Select(db.Packages.Version);&lt;/pre&gt;

&lt;p&gt;Limit number of results using Skip and Take:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;IEnumerable&amp;lt;dynamic&amp;gt; packages = packages = db.Packages
    .FindAllByTitle(&amp;quot;Simple.Data.OData&amp;quot;)
    .Take(1); 

packages = db.Packages
    .FindAllByTitle(&amp;quot;Simple.Data.OData&amp;quot;)
    .Skip(1)
    .Take(1);&lt;/pre&gt;

&lt;p&gt;Retrieve results in specific order:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;IEnumerable&amp;lt;dynamic&amp;gt; packages = db.Packages
    .FindAllByTitle(&amp;quot;Simple.Data.OData&amp;quot;)
    .OrderByDescending(db.Packages.Version);&lt;/pre&gt;

&lt;h3&gt;What’s next&lt;/h3&gt;

&lt;p&gt;OData provider already supports Insert,Update and Delete operations (more about it in a next blog post), but it does not support associations. The implementation of the new functionality requires some changes to Simple.Data.Core library that is on its way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577087" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/dynamic/default.aspx">dynamic</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/OData/default.aspx">OData</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Simple.Data/default.aspx">Simple.Data</category></item><item><title>BizTalk in the Cloud, One Step Closer Part 2</title><link>http://bloggingabout.net/blogs/jpsmit/archive/2011/12/23/biztalk-in-the-cloud-one-step-closer-part-2.aspx</link><pubDate>Thu, 22 Dec 2011 23:00:11 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577042</guid><dc:creator>Jean-Paul Smit</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;In my &lt;a href="http://bloggingabout.net/blogs/jpsmit/archive/2011/12/17/biztalk-in-the-cloud-one-step-closer.aspx" target="_blank"&gt;previous post&lt;/a&gt; I discussed a part of the recently released CTP of Windows Azure Service Bus EAI and EDI. I went over installation and the steps to take to create schemas and mappings (in this post I use different schemas and mapping, because of Visual Studio issues I had to start over).&lt;/p&gt;  &lt;p&gt;This post is about how the schemas and mappings are used in Windows Azure. Like we’re used to with BizTalk we need the schemas to define the message types and we need the mappings to transform one message type to another. But how does this all fit together?&lt;/p&gt;  &lt;p&gt;When you create a new ‘ServiceBus’ project, you’ll notice a new “BridgeConfiguration.bcs” file:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vssolutionexplorer.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;This file will contain the definition of the ‘Bridge’ between two systems connected to Azure. If you open the “bcs” file you’ll get an empty canvas and in the toolbox there are many options to fill the bridge configuration with:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vstoolbox.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;For example pick the ‘Xml One-Way Bridge’. This is one-way WCF service endpoint, opposed to the ‘Xml Request-Reply Bridge’ of which you probably guessed it to be a request/response WCF service endpoint. The canvas looks like below:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsbridge.png" width="688" height="523" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;In the solution explorer you’ll find the two schemas (SourceSchema.xsd and TargetSchema.xsd) and a mapping (Source_to_Target.trfm) I use to test with. The schema by the way is a simple mapping with a concatenation and the new if-then-else functoid (which isn’t called a functoid anymore).&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsmaptest.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Also a configuration file has been added to the solution: “XmlOneWayBridge1.BridgeConfig”, which in the end is just an XML configuration file but a so called ‘Bridge Editor’ has been created for ease of editing. Double clicking the file results in this.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsbridge2.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;In this we recognize the BizTalk pipeline! In the message types module you specify the schema&amp;#39;s you wish to be accepted by this endpoint. The validator is just an XML validator of which I assume it can be replaced by a custom component in the future. However keep in mind that this is running in the cloud so Microsoft will be careful with custom components which might impact the performance and stability of Azure.&lt;/p&gt;  &lt;p&gt;Enriching is interesting, it feels like property promotion in BizTalk. It opens the opportunity of content based routing. You can enrich from SOAP, HTTP, (SQL) Lookup and XPath. In the picture below I created XPath properties in the SourceSchema.xsd.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsenrich.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The transform module also looks familiar to BizTalk developers. Obviously only the maps that are defined as a message type in the bridge show up here:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vstransform.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;If you build the solution now, you’ll get errors. The errors indicate that without a so called ‘Connected Entity’ the message send to this end point cannot be processed. So we need to add one to the bridge configuration. In this case I’ll write the message to a queue, but that can also be an external service that the message is relayed to. When the Queue is dropped on the canvas, it can be connected to the XmlOneWayBridge by using a ‘Connection’. Be aware you can only connect on the red dots and dragging the queue shape doesn’t create a queue on the ServiceBus.&lt;/p&gt;  &lt;p&gt;Building this still results in an error about a filtering expression. This is caused by the fact that by default a filter expressing is specified on the connection to the Queue. To fix this click on the connection, select ‘Filter Condition’ and set the filter to ‘Match All’ (or specify a filter).&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsconnected.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;Now the project will build and the next step will be deploy to Azure! &lt;/p&gt;  &lt;p&gt;Because Azure EAI still is in a lab phase, you need to go to a different portal than the regular Azure Management portal: &lt;a title="https://portal.appfabriclabs.com/Default.aspx" href="https://portal.appfabriclabs.com/Default.aspx"&gt;https://portal.appfabriclabs.com/Default.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Go there and create a so called “labsubscription”. If you haven’t created such a subscription before deployment you’ll receive an error: “The remote name could not be resolved: &amp;#39;&amp;lt;servicenamespace&amp;gt;-sb.accesscontrol.appfabriclabs.com&amp;#39;” &lt;/p&gt;  &lt;p&gt;From the project file menu select ‘Deploy’ and the regular Azure deploy dialog shows up. Specify the Shared Secret and the project will be deployed:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsdeploy.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now it is time for fun by testing the bridge with the tools that come with the SDK. The set of tools contains the ‘MessageSender’ tool, which takes the account credentials, bridge URL, sample message and content type. This message was sent to the bridge:&lt;/p&gt;  &lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;    &lt;br /&gt;&amp;lt;SourceSchema xmlns=&amp;quot;&lt;a href="http://MyFirstAzureEAI.SourceSchema&amp;quot;"&gt;http://MyFirstAzureEAI.SourceSchema&amp;quot;&lt;/a&gt;&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;FirstName xmlns=&amp;quot;&amp;quot;&amp;gt;FirstName1&amp;lt;/FirstName&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;LastName xmlns=&amp;quot;&amp;quot;&amp;gt;LastName1&amp;lt;/LastName&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;Age xmlns=&amp;quot;&amp;quot;&amp;gt;1&amp;lt;/Age&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;Country xmlns=&amp;quot;&amp;quot;&amp;gt;Country1&amp;lt;/Country&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;BirthDate xmlns=&amp;quot;&amp;quot;&amp;gt;1900-01-01&amp;lt;/BirthDate&amp;gt;     &lt;br /&gt;&amp;lt;/SourceSchema&amp;gt;&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/testmessage.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;Now the message is sent to the bridge and went through the pipeline where it was transformed from ‘SourceSchema’ to ‘TargetSchema’. After the pipeline processing has been done the message is written to the queue, TestEAIQueue in my case.&lt;/p&gt;  &lt;p&gt;With another tool also from the SDK you can read messages from the queue: ‘MessageReceiver’.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/messagereceive.png" alt="" /&gt;&lt;/p&gt;      &lt;p&gt;In the message read from the queue you can derive the FirstName and LastName field from the SourceSchema have been concatenated in the TargetSchema. Also it has been derived that someone with and age of 1 is not an adult (IsAdult=false).&lt;/p&gt;  &lt;p&gt;Wow, my first BizTalk-in-the-cloud-round-trip is working!&lt;/p&gt;  &lt;p&gt;There is a lot more to discover and it is a CTP but this is working quite nice already. One thing we’re lacking in BizTalk today is the possibility to debug by pressing F5. I’m wondering if that will change with Azure EAI in the future.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.didago.nl" target="_blank"&gt;Didago IT Consultancy&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577042" width="1" height="1"&gt;</description></item><item><title>BizTalk in the Cloud, One Step Closer</title><link>http://bloggingabout.net/blogs/jpsmit/archive/2011/12/17/biztalk-in-the-cloud-one-step-closer.aspx</link><pubDate>Fri, 16 Dec 2011 23:01:46 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577018</guid><dc:creator>Jean-Paul Smit</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;We all know Microsoft is putting an enormous amount of effort in their cloud initiative called Azure. It started with compute and storage but in the mean time it has grown and more and more products are released in a cloud version before the on-premise version is released. An example is &lt;a href="http://www.microsoft.com/online/dynamics-crm-online.aspx" target="_blank"&gt;Microsoft Dynamics CRM Online&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Since the September 2011 release of Azure the &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/ee732537.aspx" target="_blank"&gt;Service Bus&lt;/a&gt; is part of it. In the service bus we find things we know from BizTalk. The most well-known ones are &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh367516.aspx" target="_blank"&gt;Queues, Topics and Subscriptions&lt;/a&gt;. This so called ‘&lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh367512.aspx" target="_blank"&gt;Brokered Messaging&lt;/a&gt;’ introduces message queuing and durable publish/subscribe messaging, which is the basis of BizTalk messaging.&lt;/p&gt;  &lt;p&gt;Of course BizTalk is capable of a lot more, but Microsoft released today the CTP of &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh689864.aspx" target="_blank"&gt;Windows Azure Service Bus EAI and EDI&lt;/a&gt;. If we take a look at this release we immediately recognize the BizTalk influences in there. It is a CTP but it is showing the direction Microsoft is going.&lt;/p&gt;  &lt;p&gt;Let’s focus on EAI for now. To install the SDK you just need a regular development machine with Windows 7/2008, .NET4 and VS2010. Download the SDK &lt;a href="http://go.microsoft.com/fwlink/?LinkId=235057" target="_blank"&gt;here&lt;/a&gt;. Installing the SDK will install some new VS templates under the section ‘ServiceBus’.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsnewproject.png" width="643" height="445" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;When the EAI project is created, the Solution Explorer looks like this:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vssolutionexplorer.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;And also new toolbox items are present, in which you’ll recognize the ServiceBus features Queues and Topics:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vstoolbox.png" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;So the first step in BizTalk development would typically be to add a schema. This can be done by the regular ‘Add Item’ option in the Solution Explorer. There the first real BizTalk items show up! We all know the Maps and Schemas!&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsnewitem.png" width="581" height="327" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;One thing that caught my eye was the extension of the mapping file, not BTM but TRFM. I can only speculate what the extension stands for.&lt;/p&gt;  &lt;p&gt;Adding the schema is nothing new since adding XSD’s has been part of Visual Studio 2010 from the beginning.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsmap.png" width="552" height="567" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Next step is creating a map, after adding the item another familiar screen shows up!&lt;/p&gt;  &lt;p&gt;As well as selecting the source and destination schema. Unfortunately it isn’t possible to drag the schemas onto the mapping canvas.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsmap2.png" width="344" height="378" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;And of course the toolbox is also familiar, although some items are missing, new or named differently from BizTalk.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vstoolbox2.png" width="258" height="774" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;This is definitely a preview of the new mapper as it will show up in the next version of BizTalk. Although the mapper has improved in BizTalk 2010, this one is even more advanced (and worth a blog post by itself!). For example I put the ‘If-Then-Else’ expression on the canvas:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.didago.nl/blog/azureeai/vsifthenelse.png" width="576" height="693" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;This is really awesome!&lt;/p&gt;  &lt;p&gt;Testing the map works quite the same way as in BizTalk, however it isn’t possible yet to generate a sample message from the schema so you need to create one yourself.&lt;/p&gt;  &lt;p&gt;Typically you would also create artifacts like orchestrations, pipelines, etc, but they are missing in this CTP. However it won’t be a surprise that at least orchestrations will show up with WF4 in the near future.&lt;/p&gt;  &lt;p&gt;So now we have a schema and a mapping, now what to do with it? Keep in mind that this is all Azure stuff so we need to deploy it into the cloud.&lt;/p&gt;  &lt;p&gt;I’ll discuss these steps in my next blog post, but we’re definitely moving towards BizTalk in the cloud! Exciting stuff!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.didago.nl" target="_blank"&gt;Didago IT Consultancy&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577018" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/jpsmit/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://bloggingabout.net/blogs/jpsmit/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Kendo UI: Managing data changes on the client and sending it back to ASP.NET MVC</title><link>http://bloggingabout.net/blogs/program.x/archive/2011/12/14/kendo-ui-managing-data-changes-on-the-client-and-sending-it-back-to-asp-net-mvc.aspx</link><pubDate>Wed, 14 Dec 2011 15:48:36 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577008</guid><dc:creator>Nathan Pledger</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;My few regular readers will know that I’m a big fan of &lt;a title="Telerik (external link)" href="http://telerik.com"&gt;Telerik&lt;/a&gt; and their products. Their product range is comprehensive, the support top-notch and their evangelism and engagement is second to none. Whilst usually involved in the .NET space from ASP.NET UI components through to testing platforms, they have recently branched out into an HTML5/JavaScript UI suite, called &lt;a title="Kendo UI (external link)" href="http://kendoui.com"&gt;Kendo UI&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The more time I spend with ASP.NET MVC, the more I learn about everything that is actually going on in a web request, which is no bad thing and highlights a fault of my own professional development; depending on ASP.NET WebForms to hide the guts of the HTTP request away from me. In gaining this “missing knowledge”, I’ve developed my JavaScript skills tremendously and as such am able to think up some sweet user experiences. &lt;/p&gt;  &lt;p&gt;My current requirement is a simple master-&amp;gt;detail data structure and editing experience. Obviously this data-structure should not require the user’s knowledge or understanding but as anyone knows, effectively creating a seamless master-&amp;gt;detail scenario without some degree of complexity or unnecessary user steps can be challenging. In playing around with the ASP.NET MVC grid it quickly became apparent that the guts of the grid control was becoming a barrier to rapid understanding and deployment, again, this considering I’m relatively new to MVC and the powered-by-unicorns “convention over configuration” pattern. What if I could rule out all the complex data-structure parsing, AJAX and the like and have the entire editing experience occur on the client?&lt;/p&gt;  &lt;p&gt;The Kendo UI suite does provide integration with the server and therefore actual data, but only insofar as facilitating AJAX requests. This is fine, as I’m fairly well versed in AJAX, JavaScript and the MVC pattern now. However, I wanted to avoid having to return to the server for “mini edits” via a full POST or AJAX. So I did not want:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Two steps: one for editing master data, the other for editing individual child data &lt;/li&gt;    &lt;li&gt;AJAX updates: updating child data in lieu of a complete POST and onward persistence (this would require some session state of some form which I am keen to avoid as this project is being developed with future cloud installation in mind) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;What I needed was complete client-side editing and a single POST.&lt;/p&gt;  &lt;p&gt;And it turns out it’s all very simple.&lt;/p&gt;  &lt;p&gt;Given the data structure:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/program.x.metablogapi/6622.LookupSet_2D00_LookupValue_5F00_01BA85A4.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="LookupSet-LookupValue" border="0" alt="LookupSet-LookupValue" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/program.x.metablogapi/8304.LookupSet_2D00_LookupValue_5F00_thumb_5F00_1A4A22F4.png" width="380" height="92" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I created the view with the KendoUI grid in, the model containing a series of properties that would hold the modifications made on the client and the controller to tie it all together.&lt;/p&gt;  &lt;h2&gt;View&lt;/h2&gt;  &lt;p&gt;The grid is easily created, much like a jQuery UI widget:&lt;/p&gt;  &lt;pre class="brush: xml;"&gt;&amp;lt;div id=&amp;quot;valuesGrid&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;

&lt;p&gt;I wanted to handle everything on the client, so in in initialising my grid, I needed to consider how I was going to do this. I decided to create a few properties in my Model, which would be rendered as hidden input elements in the form element. This would allow me to manipulate items on the client and post back the individual fields as a single POST, processing them on the server. &lt;/p&gt;

&lt;p&gt;My fields are below (in Razor syntax):&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;
@Html.HiddenFor(model=&amp;gt;model.OriginalLookupValuesJson)
@Html.HiddenFor(model =&amp;gt; model.NewLookupValuesJson)
@Html.HiddenFor(model =&amp;gt; model.EditedLookupValuesJson)
@Html.HiddenFor(model =&amp;gt; model.DeletedLookupValuesJson)
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;On the GET, the controller populates the detail records by setting the OriginalLookupValuesJson field to the JSON representation of the data-structure.&lt;/p&gt;

&lt;p&gt;On the client-side, these are manipulated by “overriding” the built-in CRUD methods of the Kendo UI grid:&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-javascript"&gt;
$(document).ready(function () {
    var json = $(&amp;#39;input#OriginalLookupValuesJson&amp;#39;).val();
    var data = eval(&amp;#39;(&amp;#39;+json+&amp;#39;)&amp;#39;);
    var dataSource = new kendo.data.DataSource({
        transport: {
            read: function (options) { 
                options.success(data);
            },
            create: function (options) {
                $(&amp;quot;input#NewLookupValuesJson&amp;quot;).val(kendo.stringify(options.data.models));
            },
            update: function (options) {
                $(&amp;quot;input#EditedLookupValuesJson&amp;quot;).val(kendo.stringify(options.data.models));
            },
            destroy: function (options) {
                $(&amp;quot;input#DeletedLookupValuesJson&amp;quot;).val(kendo.stringify(options.data.models));
            }
        }, //transport
        batch: true,
        pageSize: 4,
        schema: {
            model: {
                id: &amp;quot;ID&amp;quot;,
                fields: {
                    ID: {
                        editable: false,
                        nullable: true
                    },
                    LookupSetID: {
                        editable: false,
                        nullable: true
                    },
                    Value: {
                        editable: true,
                        validation: {
                            required: true
                        }
                    },
                    Description: {
                        editable: true
                    }
                } //fields
            }, //model
            data: &amp;quot;data&amp;quot;,
            total: function (result) {
                result = result.data || result;
                return result.length || 0;
            } //total
        } //schema
    });

    $(&amp;quot;#valuesGrid&amp;quot;).kendoGrid({
        dataSource: dataSource,
        editable: true,
        toolbar: [&amp;quot;create&amp;quot;],
        height: 250,
        scrollable: true,
        sortable: true,
        filterable: false,
        pageable: true,
        columns: [
            {
                field: &amp;quot;Value&amp;quot;,
                title: &amp;quot;Value&amp;quot;
            },
            {
                field: &amp;quot;Description&amp;quot;,
                title: &amp;quot;Description&amp;quot;
            },
            {
                command: &amp;quot;destroy&amp;quot;
            }
        ]
    });
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The script implements the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Localises the JSON from the OriginalLookupValuesJson field into a variable, which is then evaluated into a JavaScript object&lt;/li&gt;

  &lt;li&gt;A dataSource object is then configured that takes the evaluated JavaScript object as a source for the read implementation. The create, update and destroy implementations are overridden by setting their output as the previously mentioned hidden fields. The results of which will be passed back into my Controller within the Model.&lt;/li&gt;

  &lt;li&gt;Initialises and configures the grid with the dataSource variable and the user-interface aspects I require.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unfortunately, when you submit the form in a POST, the hidden fields used to monitor modifications are exactly as they were when they were requested: blank. You need to synchronise the internal data structures of the grid with the hidden fields by intercepting the form POST by adding the following BLOCKED SCRIPT&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-javascript"&gt;
$(&amp;quot;form&amp;quot;).bind(&amp;quot;submit&amp;quot;, sync);
});

function sync() {
    alert(&amp;#39;sync&amp;#39;);
    $(&amp;quot;#valuesGrid&amp;quot;).data(&amp;quot;kendoGrid&amp;quot;).dataSource.sync();
}
&lt;/code&gt;&lt;/pre&gt;



&lt;h2&gt;Model&lt;/h2&gt;

&lt;p&gt;The Model itself is supremely simple and contains the principle object of the Master object (LookupSet) and the four fields used to store the JSON and allow the manipulation of the LookupValues on the client-side and persistence of the changes on the server-side.&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;
public class LookupModel : ModelBase
{
    public LookupSet LookupSet { get; set; }
    public IEnumerable&amp;lt;SelectListItem&amp;gt; DataTypes { get; set; }
    public string OriginalLookupValuesJson { get; set; }
    public string NewLookupValuesJson { get; set; }
    public string EditedLookupValuesJson { get; set; }
    public string DeletedLookupValuesJson { get; set; }

    public LookupModel()
    {
    }

}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;I create my models within a Factory class, ModelFactory, which has a method:&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;
public static LookupModel CreateLookupModel(int id)
    {
        LookupModel model = new LookupModel(); 
        using (CoreEntities coreEntities = CoreEntitiesFactory.Create(configuration))
        {
            model.LookupSet = coreEntities.LookupSets.Include(&amp;quot;LookupValues&amp;quot;).SingleOrDefault(q =&amp;gt; q.ID == id);
            JavaScriptSerializer javaScriptSerializer=new JavaScriptSerializer();
            model.OriginalLookupValuesJson = javaScriptSerializer.Serialize(new { data = GetLookupValueModels(model) });
        }
        return model;
    }
&lt;/code&gt;&lt;/pre&gt;









&lt;p&gt;The method creates a new LookupModel and interrogates the data-store for the requested data. This is implemented using Entity Framework but obviously can be replaced with your own framework.&lt;/p&gt;

&lt;p&gt;In order to have the detail data (LookupValues) processed at the client, it needs to be serialized into JSON format, using the JavaScriptSerializer class. This is called with the result of the method GetLookupValueModels(), which is shown below:&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;
private static List&amp;lt;LookupValueModel&amp;gt; GetLookupValueModels(LookupModel model)
    {
        List&amp;lt;LookupValueModel&amp;gt; lookupValueModels = new List&amp;lt;LookupValueModel&amp;gt;();
        foreach (LookupValue lookupValue in model.LookupSet.LookupValues)
        {
            LookupValueModel lookupValueModel = new LookupValueModel()
            {
                Description = lookupValue.Description ?? string.Empty,
                ID = lookupValue.ID,
                LookupSetID = lookupValue.LookupSetID
            };
            if (model.LookupSet.DotNetDataType == typeof(string).FullName)
                lookupValueModel.Value = lookupValue.System_String;
            if (model.LookupSet.DotNetDataType == typeof(int).FullName &amp;amp;&amp;amp; lookupValue.System_Int32.HasValue)
                lookupValueModel.Value = lookupValue.System_Int32.Value.ToString();
            if (model.LookupSet.DotNetDataType == typeof(decimal).FullName &amp;amp;&amp;amp; lookupValue.System_Decimal.HasValue)
                lookupValueModel.Value = lookupValue.System_Decimal.Value.ToString();
            lookupValueModels.Add(lookupValueModel);
        }
        return lookupValueModels;
    }
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This takes the Entity Framework objects and creates a LookupValueModel for each, returning the result. This is then wrapped up in an anonymous type, which assigns the result to the “data” property. The result of which would be typically:&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-javascript"&gt;
{
    &amp;quot;data&amp;quot;: [
        {
            &amp;quot;ID&amp;quot;: 3,
            &amp;quot;LookupSetID&amp;quot;: 2,
            &amp;quot;Value&amp;quot;: &amp;quot;XXX&amp;quot;,
            &amp;quot;Description&amp;quot;: &amp;quot;Description for XXX&amp;quot;
        },
        {
            &amp;quot;ID&amp;quot;: 4,
            &amp;quot;LookupSetID&amp;quot;: 2,
            &amp;quot;Value&amp;quot;: &amp;quot;YYY&amp;quot;,
            &amp;quot;Description&amp;quot;: &amp;quot;Description for YYY&amp;quot;
        },
        {
            &amp;quot;ID&amp;quot;: 5,
            &amp;quot;LookupSetID&amp;quot;: 2,
            &amp;quot;Value&amp;quot;: &amp;quot;ZZZ&amp;quot;,
            &amp;quot;Description&amp;quot;: &amp;quot;Description for ZZZ&amp;quot;
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;As this is placed in the model property OriginalLookupValuesJson, this is sent to the client as part of the form, and correctly rendered by the Kendo UI grid component.&lt;/p&gt;

&lt;h2&gt;Controller&lt;/h2&gt;

&lt;p&gt;For completeness, the HTTP GET request is implemented by the controller as follows:&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;
public ActionResult EditLookup(int id)
    {
        ActionResult result;
        LookupModel model = ModelFactory.CreateLookupModel(id);
        if (model.LookupSet == null)
        {
            result = View(&amp;quot;InvalidLookup&amp;quot;, ModelFactory.Create&amp;lt;GenericPageModel&amp;gt;(&amp;quot;Invalid lookup&amp;quot;));
        }
        else
        {
            model.Title = string.Format(&amp;quot;Edit lookup &amp;#39;{0}&amp;#39;&amp;quot;, model.LookupSet.Name);
            result = View(&amp;quot;EditLookup&amp;quot;, model);
        }
        return result;
    }
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;But where we are interested in is the POST, which will take the modified values from the hidden form fields and implement the modifications on the data-store. The modifications arrive within the hidden fields as JSON, so it is a simple matter to rehydrate those to usable data that we can work with by deserializing the LookupValues back into CLR objects. I use the Deserialize&amp;lt;T&amp;gt;() method from this &lt;a title="Deserialize&amp;lt;T&amp;gt; StackOverflow post (external link)" href="http://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object"&gt; StackOverflow post (external link)&amp;quot; href=&amp;quot;http://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object&amp;quot;&amp;gt;StackOverflow&lt;/a&gt; post:&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;
private static T Deserialize&amp;lt;T&amp;gt;(string json)
    {
        T obj = Activator.CreateInstance&amp;lt;T&amp;gt;();
        MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json));
        DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
        obj = (T)serializer.ReadObject(ms);
        ms.Close();
        return obj;
    }
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Then I call that for each of the modification types in the HTTP POST handler of my Controller (excluding the wider persistence code):&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult EditLookup(LookupModel model)
{
    ActionResult result = View(model);
    if (ModelState.IsValid)
    {
                    List&amp;lt;LookupValueModel&amp;gt; modifiedLookupValues = Deserialize&amp;lt;List&amp;lt;LookupValueModel&amp;gt;&amp;gt;(model.EditedLookupValuesJson);
                    List&amp;lt;LookupValueModel&amp;gt; createdLookupValues = Deserialize&amp;lt;List&amp;lt;LookupValueModel&amp;gt;&amp;gt;(model.NewLookupValuesJson);
                    List&amp;lt;LookupValueModel&amp;gt; deletedLookupValues = Deserialize&amp;lt;List&amp;lt;LookupValueModel&amp;gt;&amp;gt;(model.DeletedLookupValuesJson);
    }

    return result;
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;How you handle the individual CUD methods is dependent on your persistence layer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577008" width="1" height="1"&gt;</description></item><item><title>Running Weltmeister in IIS 7</title><link>http://bloggingabout.net/blogs/chilberto/archive/2011/12/14/running-weltmeister-in-iis-7.aspx</link><pubDate>Wed, 14 Dec 2011 09:51:05 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:577007</guid><dc:creator>chilberto</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;The &lt;a href="http://impactjs.com/" target="_blank"&gt;Impact Javascript Game Engine&lt;/a&gt; comes with level editor: &lt;a href="http://impactjs.com/documentation/weltmeister" target="_blank"&gt;Weltmeister&lt;/a&gt;.&amp;#160; This is primarily built with javascript but does include some php scripting.&amp;#160; &lt;/p&gt;  &lt;p&gt;This post will hopefully save some windows developers some time getting started.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;There is also an open-source &lt;/em&gt;&lt;a href="http://code.google.com/p/impactjs-iis-backend/" target="_blank"&gt;&lt;em&gt;project&lt;/em&gt;&lt;/a&gt;&lt;em&gt; available that accomplishes this without installing PHP.&amp;#160; This accomplishes this by introducing ASPX pages which mimic the PHP scripts.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt; I am running a basic install of IIS 7.0 on Windows 7.&amp;#160; In summary, the steps I took to get the level editor to function were to install &lt;a href="http://php.iis.net/" target="_blank"&gt;PHP in IIS&lt;/a&gt; and to run the site with windows authentication.&lt;/p&gt;  &lt;h1&gt;&lt;/h1&gt;  &lt;h3&gt;Installing PHP&lt;/h3&gt;  &lt;p&gt;Setting up PHP in IIS is as a simple as using the web installer via the &lt;a href="http://php.iis.net/" target="_blank"&gt;PHP in IIS&lt;/a&gt; site and then performing some configuration of PHP in IIS.&amp;#160; There is a &lt;a href="http://learn.iis.net/page.aspx/375/set-up-fastcgi-for-php/" target="_blank"&gt;video&lt;/a&gt; regarding the steps required after the installation.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/chilberto.metablogapi/6180.image_5F00_1967635C.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/chilberto.metablogapi/1513.image_5F00_thumb_5F00_4A39F4FA.png" width="634" height="261" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Security&lt;/h3&gt;  &lt;p&gt;Because the Weltmeister must interact with the file system, sufficient access rights must be given.&amp;#160; The easiest way is to enable Windows Authentication on the site.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/chilberto.metablogapi/8311.image_5F00_5C7295EF.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/chilberto.metablogapi/1856.image_5F00_thumb_5F00_3A3A8A69.png" width="516" height="219" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=577007" width="1" height="1"&gt;</description></item><item><title>I'm in the MXP for Architects!</title><link>http://bloggingabout.net/blogs/bas/archive/2011/11/17/i-m-in-the-mxp-for-architects.aspx</link><pubDate>Thu, 17 Nov 2011 08:55:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:576126</guid><dc:creator>Bas</dc:creator><slash:comments>2</slash:comments><description>&amp;quot;the what for Architects?!&amp;quot;, you might ask yourself? MXP stands for Microsoft eXcellence Program, and is a unique collaboration between my employer (Achmea) and Microsoft, with the aim to train people, who will operate as (technical) leaders within the Microsoft community within Achmea. The participants will be intensively be trained and coached (on the job) for two years, to increase their skill on several competences: leadership communication organizational insights strategic insights...(&lt;a href="http://bloggingabout.net/blogs/bas/archive/2011/11/17/i-m-in-the-mxp-for-architects.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=576126" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/bas/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://bloggingabout.net/blogs/bas/archive/tags/training/default.aspx">training</category><category domain="http://bloggingabout.net/blogs/bas/archive/tags/MXP/default.aspx">MXP</category></item><item><title>Fast Search for SharePoint caveat: Apply a sortformula with managed properties of type decimals</title><link>http://bloggingabout.net/blogs/bas/archive/2011/11/05/fast-search-for-sharepoint-caveat-apply-a-sortformula-with-managed-properties-of-type-decimals.aspx</link><pubDate>Sat, 05 Nov 2011 08:53:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:576462</guid><dc:creator>Bas</dc:creator><slash:comments>2</slash:comments><description>Fast Search for SharePoint provides four great possibilities to influence the sort order of your resultset that was returned: Sort by Managed property Sort by Rank Sort by Formula Sort in Random order When I was working on my presentaion and demo for the diwug (Dutch Information Worker User Group) last week, to show off on how you can improve your search experience by using custom ranking models, custom sort orders and extending the pipeline, I ran into an issue that I wasn&amp;#39;t aware off. When...(&lt;a href="http://bloggingabout.net/blogs/bas/archive/2011/11/05/fast-search-for-sharepoint-caveat-apply-a-sortformula-with-managed-properties-of-type-decimals.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=576462" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/bas/archive/tags/Search/default.aspx">Search</category><category domain="http://bloggingabout.net/blogs/bas/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://bloggingabout.net/blogs/bas/archive/tags/Fast/default.aspx">Fast</category></item><item><title>Yet Another Logging Framework</title><link>http://bloggingabout.net/blogs/marc/archive/2011/10/21/yet-another-logging-framework.aspx</link><pubDate>Fri, 21 Oct 2011 11:30:27 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:576348</guid><dc:creator>Marc Jacobi</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;This blogpost is a brain dump on a new logging framework I’m planning to write. If you have any additions or suggestions please leave them as comments.&lt;/p&gt;  &lt;p&gt;So why do we need, yet another Logging Framework. Well, because I cannot find in others what I think is important and also I want to leverage the &lt;a href="http://bloggingabout.net/blogs/marc/archive/2008/04/12/a-method-context-information-gathering-framework.aspx" target="_blank"&gt;Diagnostics Trace code&lt;/a&gt; I have already written.&lt;/p&gt;  &lt;p&gt;What scenarios should this Logging Framework be able to handle?&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Easy to use.     &lt;br /&gt;It should be easy to configure and easy to call. Any provider based mechanism (log targets) is bound to have config associated with it, but at least give good feedback on any problems that might occur. Convention over configuration and MEF might ease the problems.&lt;/li&gt;    &lt;li&gt;One liner.     &lt;br /&gt;When using it, you should only have to write one line of code. This is not always feasible but it is a good starting point. Why is this important? Because you want to make it easy on the poor developer that is using your ‘yet another logging framework’. The use of Aspects (PostSharp) can also be of use.       &lt;br /&gt;On the other hand, most applications that use a 3rd party library almost always create a façade for interacting with it. So its better to have a good API that is easy to integrate into a façade than to have an awkward API in order to force it all into one line of code.&lt;/li&gt;    &lt;li&gt;Uses the TraceContext (&lt;a href="http://www.xs4all.nl/~mjacobi/Blog/Jacobi/Jacobi.Diagnostics.zip" target="_blank"&gt;source&lt;/a&gt;) information to ‘automatically’ enrich the log entries. The TraceContext now has a method to AddContectTo an Exception, but could be extended to also AddContextTo a LogEntry.&lt;/li&gt;    &lt;li&gt;Fallback log targets.     &lt;br /&gt;Have a mechanism to fallback on log targets when they are not available. This answers the question: were do you log the exception that you cannot connect to your log target.&lt;/li&gt;    &lt;li&gt;Integrated .NET support for WCF and ASP.NET.     &lt;br /&gt;Make use of the extra information that lives in those contexts and allow that context to be easily added to the log entry. Both these contexts also support some kind of interception (think Behaviors for WCF and Modules for ASP.NET) to allow automatic logging.&lt;/li&gt;    &lt;li&gt;Log to multiple log targets at the same time – each with unique filters.     &lt;br /&gt;The default System.Diagnostics TraceListeners will already do this. Also be able to retrieve different types of logs in the code (error log, message log, security audit log etc).&lt;/li&gt;    &lt;li&gt;Use that same log framework for technical logging as well as functional auditing.     &lt;br /&gt;There is no reason why a logging framework cannot be used for (more) functional logging also, provided the they use unique ‘streams’.&lt;/li&gt;    &lt;li&gt;Different log entry formats.     &lt;br /&gt;Different log targets may require different log entry structs. Still I would prefer to use the existing diagnostics code. This means that those structures has to be serialized and deserialized. I think JSON can be of great help here.&lt;/li&gt;    &lt;li&gt;Distributed and Correlated.     &lt;br /&gt;You want to be able to correlate log (and trace) entries made by different parts of the system. This allows you to get a good impression to what happened where and why.&lt;/li&gt;    &lt;li&gt;Support debug-only log entries.     &lt;br /&gt;Conditional compilation on DEBUG. No biggie, just useful.&lt;/li&gt;    &lt;li&gt;Asynchronous logging.     &lt;br /&gt;This is tough one. You want Async logging in order to minimize performance impact on the running thread – actually this is more a tracing issue than a logging issue, assuming logging doesn’t output a whole lot of entries per second). But making it asynchronous can also mean that you lose that one vital entry just before the app crashes. More on this later.&lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Using System.Diagnostics&lt;/h3&gt;  &lt;p&gt;The idea is that we use as much of the existing logging technology as possible. That means reusing and extending the main classes of the System.Diagnostics namespace. TraceSource can be derived into LogSource and provide the basis for a log target. Each LogSource can specify a collection of TraceListeners. Custom TraceListeners can be used as well as the out of the box ones.&lt;/p&gt;  &lt;p&gt;But using these TraceListseners means that all Log information has to be squeezed through a single string (essentially – worst case). This coupled with the fact that different log types might require different log entry structures leads to one conclusion. We have to serialize the complex data into a string so that it can be output by different log targets (Sinks) and mapped to their most appropriate fields.&lt;/p&gt;  &lt;p&gt;The use of JSON would be excellent here, also because JSON is somewhat readable even in its serialized form. So you can still make sense of it even when its written to a text file. The object structure that is used will be partly fixed, we will need some known fields to extract data needed for further processing. But custom structures can also be easily serialized to JSON and on the receiving side, easily serialized into generic data containers (ExpandoObjects) for use in the viewer.&lt;/p&gt;  &lt;p&gt;Formatting this complex data into something that makes sense for the specific log target is done when reading the log, not while writing it. This not only saves a little performance hit while writing the log entry, it also allows for a more versatile viewer.&lt;/p&gt;  &lt;h3&gt;Performance&lt;/h3&gt;  &lt;p&gt;One of the obvious ways to decouple the performance costs of tracing and logging is to take the processing of the log entry onto a background thread. Only the data gathering takes place on the active thread all other operations will be done on the background thread.&lt;/p&gt;  &lt;p&gt;The trouble with this is that you can lose potentially critical log entries just before your application crashes. One possibly way to have the best of both worlds is to use the log level (Critical, Error, Warning and Info) as an indication of priority. That could mean that Critical log entries are always logged on the active thread. The other levels are processed by the background thread starting with Error, Warning and Info as least significant. &lt;/p&gt;  &lt;p&gt;We have to provide some way to identify the order of these entries (can be a simple sequence number) in order to be able to view them in the correct order. Gaps in the sequence can be detected and displayed in the viewer. This mechanism will also make it easy to merge log ‘files’ from different machine into one.&lt;/p&gt;  &lt;p&gt;If we take formatting out of the write-a-log-entry process, we might also need to revisit the Tracing code we have so far in order to make that option available in Tracing too.&lt;/p&gt;  &lt;h3&gt;Reading Log entries&lt;/h3&gt;  &lt;p&gt;For each (type of) log target a Sink is needed that knows how to put the log entry data into its storage. Think for instance Enterprise Library Logging block or Log4Net or simply the event log. A TraceListener is implemented for each target that knows how to take that one string and persist it in the most optimal way.&lt;/p&gt;  &lt;p&gt;When those (types of) targets also want to play in the log viewer, they also have to expose a Provider: an object that knows how to read log entries from its storage and provide them to the viewer. &lt;/p&gt;  &lt;p&gt;The viewer will be able to union all log entries from all providers and sort them into the temporal sequence they were written in. Merging of different (machine) sources is also possible.&lt;/p&gt;  &lt;p&gt;Of course the viewer would be able to filter and even search through the entries.&lt;/p&gt;  &lt;p&gt;I think it would be advantageous to implement an &lt;a href="http://www.odata.org/" target="_blank"&gt;OData&lt;/a&gt; REST service as a source for all the log entries. This allows easy access to the log entries for all kinds of purposes and provide a flexible basis for retrieving log entry information for different applications. Both Xml and Json formatting can be supported.&lt;/p&gt;  &lt;h3&gt;Closing remarks&lt;/h3&gt;  &lt;p&gt;I am sure that a lot more issues will present themselves once a more detailed design is made and implementation starts. But I think this WILL make a pretty nice logging framework if we can pull it off. Writing this blog post has helped me to structure my thoughts more on the subject and I hope it was a pleasant read for you, perhaps even an inspiration to tweak the logging framework you are no using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=576348" width="1" height="1"&gt;</description></item><item><title>Windows Azure has best performance of cloud service providers</title><link>http://bloggingabout.net/blogs/markwillems/archive/2011/10/14/windows-azure-has-best-perfomance-of-cloud-service-providers.aspx</link><pubDate>Fri, 14 Oct 2011 11:31:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:576102</guid><dc:creator>Mark Willems</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;&lt;a href="http://www.businesscloudnews.com/applications/592-top-25-cloud-service-providers-revealed.html" title="http://www.businesscloudnews.com/applications/592-top-25-cloud-service-providers-revealed.html"&gt;http://www.businesscloudnews.com/applications/592-top-25-cloud-service-providers-revealed.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=576102" width="1" height="1"&gt;</description></item><item><title>Want to speed up your website use a CDN for commonly used files</title><link>http://bloggingabout.net/blogs/mischa/archive/2011/09/30/want-to-speed-up-your-website-use-a-cdn-for-commonly-used-files.aspx</link><pubDate>Fri, 30 Sep 2011 13:18:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:575744</guid><dc:creator>Mischa Kroon</dc:creator><slash:comments>0</slash:comments><description>Introduction Serving files from a website is easy just link to them and you&amp;#39;re done. Serving files from your website in the most optimal way isn&amp;#39;t that easy, first you have to think about things like making sure that the caching is right and if the files are being used a lot on other sites. If files are being used a lot on other sites then it could be that the user already has a copy of this file lying around, let&amp;#39;s say you use jQuery on your site. You&amp;#39;re not the only one using this...(&lt;a href="http://bloggingabout.net/blogs/mischa/archive/2011/09/30/want-to-speed-up-your-website-use-a-cdn-for-commonly-used-files.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=575744" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/mischa/archive/tags/web+development/default.aspx">web development</category><category domain="http://bloggingabout.net/blogs/mischa/archive/tags/CDN/default.aspx">CDN</category></item><item><title>Version Control by Example: Review and how to get it for free.</title><link>http://bloggingabout.net/blogs/mischa/archive/2011/09/30/version-control-by-example-review-and-how-to-get-it-for-free.aspx</link><pubDate>Fri, 30 Sep 2011 12:32:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:575743</guid><dc:creator>Mischa Kroon</dc:creator><slash:comments>0</slash:comments><description>I just read: Version Control by Example It&amp;#39;s a free printed book which can be shipped to your home for free by filling out a page full of questions. If you want the details on how to get it shipped to your home or have any questions about it find out the details here . Quick review of the book: Introduction The book gives you a quick intro about version control systems, it tells you about the history of version control systems and how they got here. What the different commands are for the version...(&lt;a href="http://bloggingabout.net/blogs/mischa/archive/2011/09/30/version-control-by-example-review-and-how-to-get-it-for-free.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=575743" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/mischa/archive/tags/SVN/default.aspx">SVN</category><category domain="http://bloggingabout.net/blogs/mischa/archive/tags/Source+Control/default.aspx">Source Control</category><category domain="http://bloggingabout.net/blogs/mischa/archive/tags/Git/default.aspx">Git</category><category domain="http://bloggingabout.net/blogs/mischa/archive/tags/Version+Control/default.aspx">Version Control</category></item><item><title>Specification Pattern Continued</title><link>http://bloggingabout.net/blogs/dries/archive/2011/09/29/specification-pattern-continued.aspx</link><pubDate>Thu, 29 Sep 2011 04:35:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:575724</guid><dc:creator>Dries Marckmann</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;sub&gt;&lt;/sub&gt;&lt;sub&gt;&lt;/sub&gt;In a previous &lt;a href="http://bloggingabout.net/blogs/dries/archive/2010/11/30/specification-pattern-implementation.aspx" target="_blank"&gt;post&lt;/a&gt;, I talked about the specification pattern. In the last sentence I promised you to keep you posted on the next version of the implementation. I still owe you guys that result. So without further ado: &lt;/p&gt;  &lt;p&gt;Download it &lt;a href="http://bloggingabout.net/media/p/575700.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The implementation itself is pretty straightforward. The class has a protected property Predicate that takes in a Lambda expression that results in a boolean ( a predicate). It is protected so that you have to set the predicate in the derived class.&lt;/p&gt;     &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;/// Use the Specification to make some complex (business) logic explicit. &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;typeparam name=&amp;quot;TEntity&amp;quot;&amp;gt;The Type of entity that is the subject of the specification&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;abstract&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Specification&amp;lt;TEntity&amp;gt;&lt;br /&gt;{&lt;br /&gt;     &lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; Func&amp;lt;TEntity, &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;&amp;gt; evalCompiled;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; Expression&amp;lt;Func&amp;lt;TEntity, &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;&amp;gt;&amp;gt; evalExpression;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;internal&lt;/span&gt; Expression&amp;lt;Func&amp;lt;TEntity, &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;&amp;gt;&amp;gt; Predicate&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; evalExpression;&lt;br /&gt;        }&lt;br /&gt;        set&lt;br /&gt;        {&lt;br /&gt;            evalExpression = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;;&lt;br /&gt;            evalCompiled = evalExpression.Compile();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// Use this method to evaluate the predicate for a single item.&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;param name=&amp;quot;item&amp;quot;&amp;gt;The item to examine&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;returns&amp;gt;A boolean.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; IsSatisfiedBy(TEntity item)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; evalCompiled(item);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// Use this method to filter IQueryables using the Predicate &lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;param name=&amp;quot;candidates&amp;quot;&amp;gt;The IQueryable that needs filtering&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#008000;"&gt;/// &amp;lt;returns&amp;gt;An IQueryable that has the added filter&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; IQueryable&amp;lt;TEntity&amp;gt; SatisfyingElementsFrom(IQueryable&amp;lt;TEntity&amp;gt; candidates)&lt;br /&gt;    {&lt;br /&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; candidates.Where(evalExpression);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;

&lt;p&gt;The usage is simple. &lt;/p&gt;

&lt;p&gt;Suppose that there is a business rule that big orders need approval by a manager. Big orders are orders above a 1000 euros. There are 2 cases when we need to know whether an order is a big order. First, when the order is created so that we can send a request for approval to the manager and second in a managers app that shows all the big orders.&lt;/p&gt;

&lt;p&gt;The class IsBigOrderSpecification is a business rule made explicit. This rule could be throughout your system. Here’s what it looks like:&lt;/p&gt;


  &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;&lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; IsBigOrderSpecification : Specification&amp;lt;SalesOrderDetail&amp;gt;&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; IsBigOrderSpecification()&lt;br /&gt;    {&lt;br /&gt;        Predicate = (o =&amp;gt; o.LineTotal &amp;gt;= 1000);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;

&lt;p&gt;When a new order is created we can now use this specification to enforce the business rule.&lt;/p&gt;


  &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;SalesOrderDetail orderLine = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; SalesOrderDetail();&lt;br /&gt;orderLine.LineTotal = 999;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; isBigOrderLine = isBigOrderLineSpec.IsSatisfiedBy(orderLine);&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (isBigOrderLine)&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine(&lt;span style="color:#006080;"&gt;&amp;quot;LineTotal {0} means this is a big orderline.&amp;quot;&lt;/span&gt;, orderLine.LineTotal);&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine(&lt;span style="color:#006080;"&gt;&amp;quot;LineTotal {0} means this is a not big orderline.&amp;quot;&lt;/span&gt;, orderLine.LineTotal);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;

&lt;p&gt;Yet the same specification can be used when querying for these big orders in the system. Because it works on IQueryable&amp;lt;SalesOrderDetail&amp;gt; we get all the advantages of deferred execution. &lt;/p&gt;


  &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;AdventureWorksEntities db = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; AdventureWorksEntities();&lt;br /&gt;&lt;br /&gt;var query = from so &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; db.SalesOrderDetails&lt;br /&gt;                        select so;&lt;br /&gt;&lt;br /&gt;var bigOrderLines = isBigOrderLineSpec.SatisfyingElementsFrom(query);&lt;br /&gt;&lt;br /&gt;Console.WriteLine(&lt;span style="color:#006080;"&gt;&amp;quot;{0} big OrderLines in database&amp;quot;&lt;/span&gt;, bigOrderLines.Count());&lt;/pre&gt;

  &lt;br /&gt;

&lt;h2&gt;&amp;#160;&lt;/h2&gt;

&lt;h2&gt;Composite specification&lt;/h2&gt;

&lt;p&gt;In the solution you can also find the code to create composite specifications. Composite specifications are specifications that have been combined. What if we changed the business rule (the manager is getting to busy) to state that only big orders from sales people that have little experience have to be approved. Little experience has been qualified at working at the company less than 2 years. You probably get an IsExperiencedSalesPersonSpecification. &lt;/p&gt;

&lt;p&gt;We are now able to combine the 2 specifications as follows: &lt;/p&gt;


  &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;background-color:#f4f4f4;margin:0em;border-left-style:none;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;border-right-style:none;font-size:8pt;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; needsApproval = isBigOrderLineSpec.And(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; IsExperiencedSalesPersonSpecification().Not()).IsSatisfiedBy(orderLine);&lt;/pre&gt;

  &lt;br /&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;My opinion is that this specification pattern is quite powerful in specifying and enforcing business rules in a distributed system.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=575724" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dries/archive/tags/Linq/default.aspx">Linq</category><category domain="http://bloggingabout.net/blogs/dries/archive/tags/IQueryable/default.aspx">IQueryable</category><category domain="http://bloggingabout.net/blogs/dries/archive/tags/pattern/default.aspx">pattern</category><category domain="http://bloggingabout.net/blogs/dries/archive/tags/specification/default.aspx">specification</category><category domain="http://bloggingabout.net/blogs/dries/archive/tags/DDD/default.aspx">DDD</category></item><item><title>How to configure AutoTest.Net to use Snarl notifications</title><link>http://bloggingabout.net/blogs/vagif/archive/2011/09/21/how-to-configure-autotest-net-to-use-snarl-notifications.aspx</link><pubDate>Wed, 21 Sep 2011 13:36:11 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:575567</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Important part of continuous testing is instant and clear notification on test results. Developer should not need to inspect small text in Visual Studio output window, test execution results should flash like traffic lights, especially when things go wrong.&lt;/p&gt;  &lt;p&gt;There are several commonly used notification applications for Windows, and &lt;a href="https://github.com/acken/AutoTest.Net" target="_blank"&gt;AutoTest.Net&lt;/a&gt; is integrated with two of them: &lt;a href="http://www.growlforwindows.com/gfw/default.aspx" target="_blank"&gt;Growl&lt;/a&gt; and &lt;a href="https://sites.google.com/site/snarlapp/home" target="_blank"&gt;Snarl&lt;/a&gt;. They provide good visualization of test execution results. Here is how Snarl notification looks:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/8004.Snarl_5F00_4266EF8E.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Snarl" border="0" alt="Snarl" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/4621.Snarl_5F00_thumb_5F00_33BC43A9.png" width="626" height="507" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;While integration with Growl works without any adjustments, Snarl needs to be configured to work with AutoTest.Net. Here is how you do it:&lt;/p&gt;  &lt;h4&gt;1. Open Snarl preference dialog&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/0435.SnarlPreference_5F00_19E80D7A.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SnarlPreference" border="0" alt="SnarlPreference" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/4744.SnarlPreference_5F00_thumb_5F00_274E2080.png" width="544" height="479" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;h4&gt;2. Go to “Network” tab and select “Yes” for “Listen for incoming Growl or Snarl notifications?&lt;/h4&gt;  &lt;h4&gt;3. Start Visual Studio (AutoTest.Net or ContinuousTests a.k.a. MightyMoose must be installed)&lt;/h4&gt;  &lt;h4&gt;4. Find and highlight “AutoTest.Net on 127.0.0.1”&lt;/h4&gt;  &lt;h4&gt;5. Highlight in “Notification Classes” “Run succeeded”, then press “Configure”&lt;/h4&gt;  &lt;h4&gt;6. Select “Yes” for “use custom icon?”&lt;/h4&gt;  &lt;h4&gt;7. Go to AutoTest.Net or ContinousTests installation folder and find in Icons subfolder circleWin.png. You should see the icon with green light:&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/4670.TestIcon_5F00_66ABD410.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="TestIcon" border="0" alt="TestIcon" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/6735.TestIcon_5F00_thumb_5F00_514E1EA8.png" width="542" height="573" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h4&gt;8. Repeat the previous step for classes “Run succeeded with warnings” and “Run failed” and choose for them icons with yellow and red light.&lt;/h4&gt;  &lt;p&gt;Now Snarl is configured to receive notifications from AutoTest.Net.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=575567" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/unit+testing/default.aspx">unit testing</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/NUnit/default.aspx">NUnit</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/AutoTest.Net/default.aspx">AutoTest.Net</category></item><item><title>How to unit test a method that has void as return type</title><link>http://bloggingabout.net/blogs/dennis/archive/2011/09/15/how-to-unit-test-a-method-that-has-void-as-return-type.aspx</link><pubDate>Thu, 15 Sep 2011 06:01:38 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:575527</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;How do I test a method that returns void? For example a method like this.&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public void Process(int leadId)
{
    decimal price = _calculator.CalculateNormalLead(leadId);

    Lead lead = new Lead(leadId, price);

    _leadRepository.Save(lead);
}&lt;/pre&gt;

&lt;p&gt;How to test what the state of the lead object is? This is a question that comes up a lot of the time. It has many different answers. Some options:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Return a type anyway, even though you don’t use it. Or expose a property with the result. This are design changes that are only neccesary for testing. I’m sure that’s not what we want. &lt;/li&gt;

  &lt;li&gt;Check what the method changed, like records in the database. That’s a slow integration test. &lt;/li&gt;

  &lt;li&gt;
    Split the methods so that one portion of it returns something, and the second method just takes the result and uses it. This way however, you’ll have to make two calls to your class, which I think is even worse than the previous two options!
  &lt;/li&gt;

  &lt;li&gt;
    Expose internals by using the InternalsVisibleTo attribute. But now you have to make changes to the design of your class again, making private methods or properties internal.
  &lt;/li&gt;

  &lt;li&gt;
    Another option is to accept you can’t test everything. What you can however check is

    &lt;ul&gt;
      &lt;li&gt;
        Check if it throws exceptions
      &lt;/li&gt;

      &lt;li&gt;
        Check if it changes mutable objects you pass in as parameters
      &lt;/li&gt;

      &lt;li&gt;
        Do interaction based testing. Either write mocks or use a mocking framework to verify if calls were made to another method.
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="left"&gt;This last thing is something we can really use. Now this might not always work, but in our case it’s very usable. Imagine we have a repository that in production kind of works like this.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class LeadRepository : ILeadRepository
{
    public void Save(Lead lead)
    {
        throw new NotImplementedException(&amp;quot;Sorry, this is for an integration test.&amp;quot;);
    }
}&lt;/pre&gt;

&lt;p align="left"&gt;Now I said kind of, because I don’t want to bother you with a lot of database and query stuff. But our lead enters this class and we’d really like to have this one! This repository implements an interface and the class is injected into the &lt;em&gt;Invoicing&lt;/em&gt; class, where our &lt;em&gt;Process&lt;/em&gt; method is. For the complete example, check the solution. But for now, check out this &lt;em&gt;FakeRepository&lt;/em&gt; I created to use during testing.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class FakeRepository : ILeadRepository
{
    public Lead CreatedLead { get; private set; }

    public void Save(Lead lead)
    {
        CreatedLead = lead;
    }
}&lt;/pre&gt;

&lt;p align="left"&gt;The only thing this repository does, is put the lead it receives into a property of the &lt;em&gt;FakeRepository&lt;/em&gt; class. Remember that the repository in production does not have this property, so normally it’s never exposed.&lt;/p&gt;

&lt;p&gt;Now we can write a test that injects our own fake objects and when asserting, we use the property of our FakeRepository to check the state of our lead.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;[TestMethod]
public void Does_MapPropertiesCorrectly_When_CalculatingALead()
{
    // Arrange
    int leadId = 1;
    decimal leadPrice = 0.5m;
    FakeRepository fakeRepository = new FakeRepository();
    FakeCalculator calculator = new FakeCalculator(leadPrice);

    // Act
    Invoicing invoicing = new Invoicing(calculator, fakeRepository);
      invoicing.Process(leadId);

    // Assert
    Lead result = fakeRepository.CreatedLead;
    Assert.AreEqual(leadId, result.LeadId);
    Assert.AreEqual(leadPrice, result.Price);
}&lt;/pre&gt;

&lt;p&gt;See how easy it sometimes is? Download the &lt;a href="http://bloggingabout.net/media/p/575526.aspx"&gt;complete solution here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=575527" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Development/default.aspx">Development</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Agile/default.aspx">Agile</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Locking in SQL Server and the nolock and readpast hints</title><link>http://bloggingabout.net/blogs/dennis/archive/2011/09/13/locking-in-sql-server-and-the-nolock-and-readpast-hints.aspx</link><pubDate>Tue, 13 Sep 2011 14:25:30 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:574467</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I’ve written about transactions, the TransactionScope in .NET before.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/02/09/11011.aspx"&gt;System.Transactions : An introduction&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/02/10/11017.aspx"&gt;System.Transactions : Unit Testing&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/03/20/11748.aspx"&gt;System.Transactions : Promotable Enlistment&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2007/06/28/system-transactions-still-not-working.aspx"&gt;System.Transactions still not working&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/12/18/system-transactions-readuncommitted.aspx"&gt;System.Transactions : Read Uncommitted&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://bloggingabout.net/blogs/dennis/archive/2006/09/27/System.Transactions-_3A00_-What-to-choose_3F00_.aspx"&gt;System.Transactions : What to choose?&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Still I was recently surprised with the comment that I had to use the READPAST in my queries. So I started investigating and felt I had to blog about this. First of all, I’m not going to discuss every option here, just a few basics so you get what the differences are.&amp;#160; If you want to know&amp;#160; more, check out the BOL/MSDN documentation. Here’s a good &lt;a href="http://msdn.microsoft.com/en-us/library/aa213037(v=SQL.80).aspx"&gt;starting point&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I’ve created a demo to show locking mechanisms. The database I used was the only one at hand at the time I wrote this, and it’s the Cookbook database from &lt;a href="http://www.dennisdoomen.net/"&gt;Dennis Doomen&lt;/a&gt; his &lt;a href="http://www.dennisdoomen.net/2011/03/introducing-silverlight-cookbook.html"&gt;Silverlight Cookbook example&lt;/a&gt;. It only has one table and a full select outputs the following result in my case.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/3107.cookbookdatabase_5F00_5F2440BF.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;padding-top:0px;" title="cookbookdatabase" border="0" alt="cookbookdatabase" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/dennis.metablogapi/2502.cookbookdatabase_5F00_thumb_5F00_45BC3D85.png" width="553" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Shared Locks      &lt;br /&gt;&lt;/strong&gt;First I want to tell about Shared Locks. Normally when you start a transaction like the code below, you place a shared lock until the transactions is over. A shared lock means someone else is still able to read the data you’ve locked, they just now allowed to update it. Because you want to be sure that the data you read, is still the same at the time you commit a transaction (to update data, for example).&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;SqlCommand cmd = new SqlCommand();
cmd.Connection = GetConnection();
cmd.CommandText = &amp;quot;select * from Recipes with (readpast)&amp;quot;;
var reader = cmd.ExecuteReader();&lt;/pre&gt;

&lt;p&gt;The GetConnection() method initiates and opens a connection to my database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ReadCommitted transaction&lt;/strong&gt; 

  &lt;br /&gt;A regular transaction is done with isolation level ‘ReadCommitted’. This means that you cannot read data that has an exclusive lock on it. This is achieved when you update a row and another transaction tries to read it while you still have your transaction open. Here’s the update code.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;TransactionOptions transactionOptions = new TransactionOptions();
transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew,transactionOptions))
{
    SqlConnection con = new SqlConnection();
    con.ConnectionString = ConnectionString;
    con.Open();

    SqlCommand cmd = new SqlCommand();
    cmd.Connection = con;
    cmd.CommandText = &amp;quot;update Recipes set Description = &amp;#39;ChangedDescription&amp;#39; where Id = 1&amp;quot;;                
    cmd.ExecuteNonQuery();
}&lt;/pre&gt;

&lt;p&gt;And here’s the code in another transaction that tries to read it.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;SqlCommand cmd = new SqlCommand();
cmd.Connection = GetConnection();
cmd.CommandText = &amp;quot;select * from Recipes&amp;quot;;
var reader = cmd.ExecuteReader();

while (reader.Read())
{
    Console.WriteLine(&amp;quot;Description : {0}&amp;quot;, reader[&amp;quot;Description&amp;quot;].ToString());
}&lt;/pre&gt;

&lt;p&gt;The second method should not be able to retrieve data from the table until the transactions is closed. The original transaction can place multiple kinds of locks, including a lock that concerns the entire table. The select query I wrote just simply retrieves everything, and as the first row (at least) is locked, it’s not able to retrieve anything. If you add a where clause to filter out just the second row, it should be able to load the data anyway.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOLOCK hint 
    &lt;br /&gt;&lt;/strong&gt;So with the NOLOCK / READUNCOMMITTED hint/isolation-level, you tell your transaction (or query) that you want to read dirty data. Even though the transaction hasn’t been committed yet, you still want to read its data. A problem can occur that when the other transaction is rolled back, you’ve loaded data that isn’t there anymore. Worse yet, when SQL Server decides to shift data between different pages, you might simply loose a lot of data because it’s not there!&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;SqlCommand cmd = new SqlCommand();
cmd.Connection = GetConnection();
cmd.CommandText = &amp;quot;select * from Recipes with (nolock)&amp;quot;;
var reader = cmd.ExecuteReader();&lt;/pre&gt;

&lt;p&gt;The result is that you get the change from the update statement. But because we never commit anything, everything is rolled back and we’ve read a dirty state.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;Description : ChangedDescription
Description : Description2
Description : Description3
Description : Description4&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;READPAST hint 
    &lt;br /&gt;&lt;/strong&gt;Now with the READPAST hint you’re telling SQL Server you do NOT want to read dirty data. Instead, it skips the rows that are locked.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;SqlCommand cmd = new SqlCommand();
cmd.Connection = GetConnection();
cmd.CommandText = &amp;quot;select * from Recipes with (readpast)&amp;quot;;
var reader = cmd.ExecuteReader();&lt;/pre&gt;

&lt;p&gt;Result is first row not being shown at all! So when we change the update query to ‘where Id = 1 or Id = 2’ we get one row less in the other select query.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;Description : Description2
Description : Description3
Description : Description4&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Conclusion 
    &lt;br /&gt;&lt;/strong&gt;Be very, very aware of the problems you might introduce when using these table hints!&lt;/p&gt;

&lt;p&gt;Download the &lt;a href="http://bloggingabout.net/media/p/575524.aspx"&gt;demo solution&lt;/a&gt; here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=574467" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Development/default.aspx">Development</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>Value of Unit testing</title><link>http://bloggingabout.net/blogs/dennis/archive/2011/09/12/value-of-unit-testing.aspx</link><pubDate>Mon, 12 Sep 2011 13:17:27 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:573350</guid><dc:creator>Dennis van der Stelt</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;There are probably uncountable amount of articles, posts and arguments on to why Unit Testing is so valuable. I just found a nice example that would’ve (or at least should’ve) been caught using Unit Tests. The following code was a bit adjusted to the need of this post, but has a mistake. See if you can spot it.&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public class Discount
{
    public Discount(decimal percentage, DateTime startDate, DateTime endDate)
    {
        endDate.Add(new TimeSpan(23,59,59));

        Percentage = percentage;
        StartDate = startDate;
        EndDate = endDate;            
    }

    public decimal Percentage { get; private set; }
    public DateTime StartDate { get; private set; }
    public DateTime EndDate { get; private set; }
}&lt;/pre&gt;

&lt;p&gt;If you haven’t spotted it, I’d advise you to write a unit test to show that it’s failing. Here’s mine.
  &lt;br /&gt;I’ve used &lt;a href="http://fluentassertions.codeplex.com/"&gt;FluentAssertions&lt;/a&gt; by the way, a library I love that helps me assert my code more easily.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;[TestMethod]
public void Does_MapPropertiesCorrectly_When_CreatingNormalDiscount()
{
    // Act
    Discount discount = new Discount(5, new DateTime(2001, 9, 11), new DateTime(2011, 9, 11));

    // Assert
    discount.EndDate.Should().Be(new DateTime(2011, 9, 11, 23, 59, 59));
}&lt;/pre&gt;

&lt;p&gt;What is says is that it’s still 2011/9/11 00:00:00 instead of at the last second of that day. The problem here is that the endDate.Add method adheres to the framework guidelines. That is that you can’t edit an object you get passed by external source, only return new values. So the Add method returns a new DateTime object. We can make the test working with the following adjustment.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class Discount
{
    public Discount(decimal percentage, DateTime startDate, DateTime endDate)
    {
        endDate = endDate.Add(new TimeSpan(23,59,59));

        Percentage = percentage;
        StartDate = startDate;
        EndDate = endDate;            
    }

    public decimal Percentage { get; private set; }
    public DateTime StartDate { get; private set; }
    public DateTime EndDate { get; private set; }
}&lt;/pre&gt;

&lt;p&gt;The only change I made was on line 5.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=573350" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/dennis/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Record Skype</title><link>http://bloggingabout.net/blogs/fadzai/archive/2011/09/07/record-skype.aspx</link><pubDate>Wed, 07 Sep 2011 13:54:49 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:567999</guid><dc:creator>Fadzai Chamba</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;Just saw this on Channel 9 - &lt;a title="http://bit.ly/ojq6Hk" href="http://bit.ly/ojq6Hk"&gt;http://bit.ly/ojq6Hk&lt;/a&gt;. It refers to a blog post by &lt;a href="http://galratner.com/blogs/" target="_blank"&gt;Gal Ratner&lt;/a&gt;, &lt;a title="http://bit.ly/p093H7" href="http://bit.ly/p093H7"&gt;http://bit.ly/p093H7&lt;/a&gt;. Discussion on Skype API and source code for how to attach to Skype process and redirect conversations allowing you to record them. Check it out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=567999" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/fadzai/archive/tags/.NET/default.aspx">.NET</category><category domain="http://bloggingabout.net/blogs/fadzai/archive/tags/Coding+4+Fun/default.aspx">Coding 4 Fun</category></item><item><title>Something you REALLY should know about dates ! (beeing Kind to DateTime.Kind)</title><link>http://bloggingabout.net/blogs/wellink/archive/2011/09/02/something-you-really-should-know-about-dates-beeing-kind-to-datetime-kind.aspx</link><pubDate>Fri, 02 Sep 2011 14:07:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:562635</guid><dc:creator>Patrick Wellink</dc:creator><slash:comments>0</slash:comments><description>Here we go, some important stuff about dates.....(it&amp;#39;s not only BizTalk related) I had a very simple scenario. Webservice Receives a request (with several datetime fields in it) Send the received message to SQL via the WCF adapter For some obscure reason some datetime values originating from the same WebRequest got modified once in the database and some did not. After some tracing we found that the dates were serialized in a different way once inside the webservice. some of the formats we saw...(&lt;a href="http://bloggingabout.net/blogs/wellink/archive/2011/09/02/something-you-really-should-know-about-dates-beeing-kind-to-datetime-kind.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=562635" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/wellink/archive/tags/BizTalk/default.aspx">BizTalk</category><category domain="http://bloggingabout.net/blogs/wellink/archive/tags/DateTime/default.aspx">DateTime</category></item><item><title>Evolution of Windows Explorer</title><link>http://bloggingabout.net/blogs/andries/archive/2011/08/30/evolution-of-windows-explorer.aspx</link><pubDate>Tue, 30 Aug 2011 13:05:15 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:560301</guid><dc:creator>Andries van der Meulen</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Nice post of Steven Sinofsky on MSDN blogs about the history and future of Windows Explorer.    &lt;br /&gt;&lt;a title="http://blogs.msdn.com/b/b8/archive/2011/08/29/improvements-in-windows-explorer.aspx" href="http://blogs.msdn.com/b/b8/archive/2011/08/29/improvements-in-windows-explorer.aspx"&gt;http://blogs.msdn.com/b/b8/archive/2011/08/29/improvements-in-windows-explorer.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="1"&gt;(edit 31-08-2011)&lt;/font&gt;    &lt;br /&gt;And Martin Tirion of Microsoft Netherlands wrote about it a day later (in Dutch).    &lt;br /&gt;&lt;a title="http://blogs.microsoft.nl/blogs/ux/archive/2011/08/30/windows-explorer-in-windows-8-en-user-experience.aspx" href="http://blogs.microsoft.nl/blogs/ux/archive/2011/08/30/windows-explorer-in-windows-8-en-user-experience.aspx"&gt;http://blogs.microsoft.nl/blogs/ux/archive/2011/08/30/windows-explorer-in-windows-8-en-user-experience.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=560301" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/andries/archive/tags/User+Experience+Design/default.aspx">User Experience Design</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/Design/default.aspx">Design</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/Ribbon/default.aspx">Ribbon</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/Windows+8/default.aspx">Windows 8</category></item><item><title>Article Published in Dutch .NET Magazine</title><link>http://bloggingabout.net/blogs/jpsmit/archive/2011/08/28/article-published-in-dutch-net-magazine.aspx</link><pubDate>Sun, 28 Aug 2011 12:01:43 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:559206</guid><dc:creator>Jean-Paul Smit</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;Just before my holiday started, I got the great news that my article on the BizTalk Software Factory had been published on the Dutch .NET magazine site! It is my first article ever!&lt;/p&gt;  &lt;p&gt;The &lt;a href="http://bsf.codeplex.com" target="_blank"&gt;BizTalk Software Factory&lt;/a&gt; is a community tool that helps BizTalk developers build consistent solutions.&lt;/p&gt;  &lt;p&gt;Together with Mr. Dijkstra I wrote an article to explain the advantages of using the BizTalk Software Factory. The concepts of the BizTalk Software Factory can be applied to other technologies as well though.&lt;/p&gt;  &lt;p&gt;You can find the article &lt;a href="http://www.dotnetmag.nl/Artikel/1628/Consistente-BizTalk-solutions-bouwen-met-de-BizTal" target="_blank"&gt;here&lt;/a&gt;, but keep in mind it is in Dutch…&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.didago.nl" target="_blank"&gt;Didago IT Consultancy&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=559206" width="1" height="1"&gt;</description></item><item><title>Datadrop Website Load Tool</title><link>http://bloggingabout.net/blogs/andries/archive/2011/08/23/datadrop-website-load-tool.aspx</link><pubDate>Tue, 23 Aug 2011 15:41:25 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:554941</guid><dc:creator>Andries van der Meulen</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In the last months I’ve experienced a lot of problems with my current internet connection. Due to mysterious reasons there have been data-drops at random times for random periods.&lt;/p&gt;  &lt;p&gt;I’ve contacted my ISP (Online.nl), and told them my story. But every time they’ve called me back, they said that they could not find the problem. My connection was always fine.&lt;/p&gt;  &lt;p&gt;Irritated by the fact that they could not solve my problem, I asked them what they would need to fix the problem. They answered that they need proof of the failing connection. &lt;/p&gt;  &lt;p&gt;So I’ve created a solution.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;At the moment they probably are only testing with pings, and my problem isn’t actually a failing connection, but data-loss due package-drops.     &lt;br /&gt;So I’ve searched for an small application that I can run on my HomeServer, which measures the internet connection.     &lt;br /&gt;Unfortunately I have only found Ping-testers, which wasn’t exactly where I was looking for. &lt;/p&gt;  &lt;p&gt;Therefore I’ve decided to build my own tester.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Website Load Tool&lt;/strong&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/andries.metablogapi/6170.screenshot_5F00_06EA52E3.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="screenshot" border="0" alt="screenshot" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/andries.metablogapi/5516.screenshot_5F00_thumb_5F00_0388BB3B.png" width="534" height="388" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The website load tool is a small application build on WPF .Net 4 that will download data with a configurable interval from defined URI’s.    &lt;br /&gt;So you set up a series of websites with an test interval of 60 seconds, and keep it running for several days.     &lt;br /&gt;Changes of state are written in a Log, so you can collect you own evidence of the stability of your connection.&lt;/p&gt;  &lt;p&gt;I’ve released the application on CodePlex, so everybody is free to use it.    &lt;br /&gt;It also can come in handy if you need to check network-stability or the availability of your website.&lt;/p&gt;  &lt;p&gt;Get it at &lt;a href="http://websiteloadtool.codeplex.com/" target="_blank"&gt;websiteloadtool.codeplex.com&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=554941" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/andries/archive/tags/CodePlex/default.aspx">CodePlex</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/WPF/default.aspx">WPF</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/Ribbon/default.aspx">Ribbon</category><category domain="http://bloggingabout.net/blogs/andries/archive/tags/Website+Load+Tool/default.aspx">Website Load Tool</category></item></channel></rss>
