<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Roger Alsing Weblog</title>
	<atom:link href="http://rogeralsing.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rogeralsing.com</link>
	<description></description>
	<lastBuildDate>Mon, 07 May 2012 13:10:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rogeralsing.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Roger Alsing Weblog</title>
		<link>http://rogeralsing.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rogeralsing.com/osd.xml" title="Roger Alsing Weblog" />
	<atom:link rel='hub' href='http://rogeralsing.com/?pushpress=hub'/>
		<item>
		<title>Re-uploaded files</title>
		<link>http://rogeralsing.com/2012/02/23/re-uploaded-files/</link>
		<comments>http://rogeralsing.com/2012/02/23/re-uploaded-files/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 08:16:01 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1040</guid>
		<description><![CDATA[My old file host is down so here are some of the old downloads: Genetic Math Gold Parser Sample<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1040&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My old file host is down so here are some of the old downloads:</p>
<p><a href="http://dl.dropbox.com/u/63708110/GenMath.rar">Genetic Math</a></p>
<p><a href="http://dl.dropbox.com/u/63708110/GoldLinq.zip">Gold Parser Sample</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/1040/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1040&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2012/02/23/re-uploaded-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Fake Fibers using Async CTP</title>
		<link>http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/</link>
		<comments>http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 10:39:52 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# 5 Async]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1004</guid>
		<description><![CDATA[This is another PoC, building recursive code with continuations using the Async CTP. The code creates a fake fiber, which can be suspended and resumed, thus allowing us to &#8220;step&#8221; through its actions. This technique could be useful when building an &#8230; <a href="http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1004&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is another PoC, building recursive code with continuations using the Async CTP.</p>
<p>The code creates a fake fiber, which can be suspended and resumed, thus allowing us to &#8220;step&#8221; through its actions.<br />
This technique could be useful when building an interpreting language where you might want to step through the expressions.</p>
<p><pre class="brush: csharp;">
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Runtime.CompilerServices;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            FakeFiber f = new MyFiber();

            f.Run();
            while (true)
            {
                //tell fiber to continue
                f.Continue();
                Console.ReadLine();
            }
        }
    }

    public class MyFiber : FakeFiber
    {

        //recursive loop that never throws stack overflow
        async void DoLoop(int count)
        {
            await Yield(); //clear callstack

            Console.WriteLine(&quot;{0} {1}&quot;, count, System.Threading.Thread.CurrentThread.ManagedThreadId); 
            
            //we can fetch values from other functions too
            //w/o blowing the call stack
            var i = await IntFunc();
            
            Console.WriteLine(&quot;got func result {0}&quot;,i);
                     
            if (count == 0)
                return;

            DoLoop(count - 1);
        }

        private async Task&lt;int&gt; IntFunc()
        {
            await Yield(); //clear callstack
            return 1;
        }

        public override void Run()
        {
            DoLoop(100000);
        }
    }

    public abstract class FakeFiber
    {
        public abstract void Run();
        private Task currentTask;
        public bool IsCompleted = false;
        public void Continue()
        {
            var task = currentTask;
            if (task != null)
            {
                task.Start();
                task.Wait();
            }
        }

        protected Task Yield()
        {
            currentTask = new Task(() =&gt; { this.currentTask = null; });
            return currentTask;
        }
    }
}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1004/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/1004/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/1004/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/1004/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/1004/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/1004/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/1004/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1004&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>F# style Mailbox / Agent using C# async CTP</title>
		<link>http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/</link>
		<comments>http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 08:33:54 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=997</guid>
		<description><![CDATA[More info on TPL DataFlow can be found here : http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d5b3e1f8-c672-48e8-baf8-94f05b431f5c Here is a (naive) F# style Mailbox / Agent using the C# async CTP : This way, we can spawn thousands of agents w/o allocating threads for each of &#8230; <a href="http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=997&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>More info on TPL DataFlow can be found here : <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d5b3e1f8-c672-48e8-baf8-94f05b431f5c">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d5b3e1f8-c672-48e8-baf8-94f05b431f5c</a></p>
<p>Here is a (naive) F# style Mailbox / Agent using the C# async CTP :</p>
<p><pre class="brush: csharp;">
    class Program
    {
        static void Main(string[] args)
        {
            var agents = new List&lt;MyAgent&gt;();
            //create 100 000 agents
            for (int i = 0; i &lt; 100000; i++)
                agents.Add(new MyAgent());

            //buffer some messages
            agents.AsParallel().ForAll(a =&gt; a.Send(DateTime.Now.ToString()));

            //start agents
            agents.AsParallel().ForAll(a =&gt; a.Run());

            //send some more messages
            agents.AsParallel().ForAll(a =&gt; a.Send(DateTime.Now.ToString()));

            Console.ReadLine();
        }
    }

    public class MyAgent : Mailbox&lt;string&gt;
    {
        
        public override async void Run()
        {
            while (true)
            {
                var message = await Receive();                
                Console.WriteLine(&quot;Agent {0} got {1}&quot;,this.Id, message);
            }
        }
    }

    public abstract class Mailbox&lt;T&gt;
    {
        private static int id;

        protected Mailbox()
        {
            this.Id = id++;
        }

        public int Id { get;protected set; }

        BufferBlock&lt;T&gt; buffer = new BufferBlock&lt;T&gt;();

        
        public abstract void Run();
        
        
        public void Send(T message)
        {
            buffer.SendAsync(message);
        }

        protected async Task&lt;T&gt; Receive()
        {
            return await buffer.ReceiveAsync();
        }
    }
</pre></p>
<p>This way, we can spawn thousands of agents w/o allocating threads for each of them.<br />
The message loop is executed on the threadpool for each iteration and then suspended untill a new message arrives.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/997/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/997/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=997&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Consuming WCF services in Silverlight using Async CTP</title>
		<link>http://rogeralsing.com/2011/04/14/consuming-wcf-services-in-silverlight-using-async-ctp/</link>
		<comments>http://rogeralsing.com/2011/04/14/consuming-wcf-services-in-silverlight-using-async-ctp/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 10:57:25 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=992</guid>
		<description><![CDATA[Here is a small sample of how you can consume WCF services using the new Async CTP features. Example, filling a listbox with categories of some sort.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=992&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a small sample of how you can consume WCF services using the new Async CTP features.</p>
<p><strong>Example, filling a listbox with categories of some sort.</strong><br />
<pre class="brush: csharp;">
private async void FillCategories()
{
    var client = new MyServiceReference.MyServiceClient();
    //yield untill all categories have been fetched.
    var categories = await client.GetCategoriesTaskAsync();
    categoriesListBox.DataContext = categories;
}

..elsewhere..

//this extension makes it possible to get a Task of T back from our service client
public static class MyServiceClientExtensions
{
    public static Task&lt;IList&lt;Category&gt;&gt; 
                GetCategoriesTaskAsync(this MyServiceClient client)
    {
        var taskCompletion = new TaskCompletionSource&lt;IList&lt;Category&gt;&gt;();
        client.GetCategoriesCompleted += (s, e) =&gt;
                {
                    if (e.Error != null)
                        taskCompletion.TrySetException(e.Error);
                    else
                        taskCompletion.TrySetResult(e.Result);
                };
        client.GetCategoriesAsync();

        return taskCompletion.Task;
    }  
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/992/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/992/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/992/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/992/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/992/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/992/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/992/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=992&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/14/consuming-wcf-services-in-silverlight-using-async-ctp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Async CTP first impressions</title>
		<link>http://rogeralsing.com/2011/04/14/async-ctp-first-impressions/</link>
		<comments>http://rogeralsing.com/2011/04/14/async-ctp-first-impressions/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 08:07:29 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=989</guid>
		<description><![CDATA[This is just my first observations. nothing fancy.. I&#8217;ve just installed the new Async CTP (for C# 5 async features) The SP1 Refresh can be found here: http://msdn.microsoft.com/sv-se/vstudio/async/ The new async and await features makes async programming so much sweeter, it lets you write &#8230; <a href="http://rogeralsing.com/2011/04/14/async-ctp-first-impressions/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=989&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is just my first observations. nothing fancy..</p>
<p>I&#8217;ve just installed the new Async CTP (for C# 5 async features)<br />
The SP1 Refresh can be found here: <a href="http://msdn.microsoft.com/sv-se/vstudio/async/">http://msdn.microsoft.com/sv-se/vstudio/async/</a></p>
<p>The new async and await features makes async programming so much sweeter, it lets you write async code in a sequential manner.<br />
e.g.</p>
<p><pre class="brush: csharp;">
static async void ShowGoogleHtmlCode()
{
  WebClient client = new WebClient();
   var result = await client.DownloadStringTaskAsync(&quot;http://www.google.com&quot;);
   Console.WriteLine(result);
}
</pre></p>
<p>This code looks sequential, but the code will return/yield back to the caller when it hits the &#8220;await&#8221; keyword.<br />
Once the expression after &#8220;await&#8221; completes, the code will continue to run.</p>
<p>So far so good.<br />
However, there are some design considerations.</p>
<p>Consider this:</p>
<p><pre class="brush: csharp;">
public async void SetupUi()
{
  var blogService = new BlogServiceClient();
     var categories = await blogService.GetCategories();
  var latestPosts = away blogService.GetLatestPosts();

     this.Categories.DataSource = categories;
     this.Posts.DataSource = latestPosts;
}
</pre></p>
<p>This code will call GetCategories and GetLatestPosts at the same time and then wait for _both_ of them to complete before continuing to fill the GUI elements.<br />
If you are doing a Silverlight app, then you probably want to display each GUI element as soon as possible, and thus, the above code could be rewritten to:</p>
<p><pre class="brush: csharp;">
public async void SetupUi()
{
  SetupCategories();
  SetupPosts();
}

public async void SetupCategories()
{
  var blogService = new BlogServiceClient();
     var categories = await blogService.GetCategories();
     this.Categories.DataSource = categories;
}

public async void SetupPosts()
{
  var blogService = new BlogServiceClient();
  var latestPosts = away blogService.GetLatestPosts();
     this.Posts.DataSource = latestPosts;
}
</pre></p>
<p>This way, the async calls will be independent of each other and fill the corresponding GUI element once the data it needs has been fetched.</p>
<p>Also, if you were to write the first code in this way:</p>
<p><pre class="brush: csharp;">
public async void SetupUi()
{
  var blogService = new BlogServiceClient();
     var categories = await blogService.GetCategories();
     this.Categories.DataSource = categories;

  var latestPosts = away blogService.GetLatestPosts();
     this.Posts.DataSource = latestPosts;
}
</pre></p>
<p>In this case, the call to GetCategories would be invoked, and the code waits for it to complete.<br />
Once the categories have been fetched, the GUI element is filled and _then_ the call to GetLatestPost() would be invoked.<br />
Thus, the async calls would not execute at the same time and the time span for the SetupUI to complete would be the same as if all of it were sync code.</p>
<p>Thats all for now..</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/989/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=989&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/14/async-ctp-first-impressions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Essentials of Metaheuristics</title>
		<link>http://rogeralsing.com/2011/04/12/essentials-of-metaheuristics/</link>
		<comments>http://rogeralsing.com/2011/04/12/essentials-of-metaheuristics/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 18:32:40 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Evolution]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=987</guid>
		<description><![CDATA[Essentials of Metaheuristics is now available on Amazon.com http://www.amazon.com/Essentials-Metaheuristics-Sean-Luke/dp/0557148596/ (Featuring EvoLisa inspired images ;-) )<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=987&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Essentials of Metaheuristics is now available on Amazon.com</p>
<p><a href="http://www.amazon.com/Essentials-Metaheuristics-Sean-Luke/dp/0557148596/">http://www.amazon.com/Essentials-Metaheuristics-Sean-Luke/dp/0557148596/</a></p>
<p>(Featuring EvoLisa inspired images ;-) )</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/987/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/987/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/987/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/987/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/987/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/987/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/987/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/987/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/987/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/987/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/987/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/987/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/987/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/987/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=987&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/12/essentials-of-metaheuristics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>O/R Mapping and domain query optimizations</title>
		<link>http://rogeralsing.com/2011/04/01/or-mapping-and-domain-query-optimizations/</link>
		<comments>http://rogeralsing.com/2011/04/01/or-mapping-and-domain-query-optimizations/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 08:54:57 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[O/R Mapping]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[EF4]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=977</guid>
		<description><![CDATA[One of the cons of O/R mapping is that the abstraction is a bit too high. You write object-oriented code and often forget about eventual performance problems. Take this (somewhat naive) example: For a given customer, we iterate over all &#8230; <a href="http://rogeralsing.com/2011/04/01/or-mapping-and-domain-query-optimizations/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=977&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the cons of O/R mapping is that the abstraction is a bit too high.<br />
You write object-oriented code and often forget about eventual performance problems.</p>
<p>Take this (somewhat naive) example:</p>
<p><pre class="brush: csharp;">
class Customer
{
   ...
  public double GetOrderTotal()
   {
       var total = ( from order in this.Orders
                        from detail in order.Details
                        select detail.Quantity * detail.ItemPrice)
                       .Sum();

       return total;
   }
}
</pre></p>
<p>For a given customer, we iterate over all the orders and all the details in those orders and calculate the sum of quantity multiplied with itemprice.<br />
So far so good.</p>
<p>This will work fine as long as you have all the data in memory and the dataset is not too large, so chances are that you will not notice any problems with this code in your unit tests.</p>
<p>But what happens if the data resides in the database and we have 1000 orders with 1000 details each?<br />
Now we are in deep s##t, for this code to work, we need to materialize at least 1 (cust) + 1000 (orders) * 1000 (details) entities.<br />
The DB needs to find those 1 000 001 rows , the network needs to push them from the DB server to the App server and the App server needs to materialize all of it.<br />
Even worse, what if you have lazy load enabled and aren&#8217;t loading this data using eager load?<br />
Then you will hit the DB 1 000 001 times&#8230; GL with that! :-)</p>
<p>So clearly, we can not do this in memory, neither with lazy load nor eager load.</p>
<p>But what are the alternatives?<br />
Make an ad hoc sql query?<br />
In that case, what happens to your unit tests?</p>
<p>Maybe we want to keep this code, but we want to execute it in the database instead.</p>
<p>This is possible if we stop beeing anal about &#8220;pure POCO&#8221; or &#8220;no infrastructure in your entities&#8221;</p>
<p>Using an unit of work container such as <a href="https://github.com/rogeralsing/Precio.Infrastructure">https://github.com/rogeralsing/Precio.Infrastructure</a></p>
<p>We can then rewrite the above code slightly:</p>
<p><pre class="brush: csharp;">
class Customer
{
   ...
  public double GetOrderTotal()
   {
  var total = ( from customer in UoW.Query&lt;Customer&gt;() //query the current UoW
                        where customer.Id == this.Id //find the persistent record of &quot;this&quot;
                        from order in customer.Orders
                        from detail in order.Details
                        select detail.Quantity * detail.ItemPrice)
                       .Sum();

       return total;
   }
}
</pre></p>
<p>This code will run the query inside the DB if the current UoW is a persistent UoW.<br />
If we use the same code in our unit tests and use an in mem UoW instance, this code will still work, if our customer is present in the in mem UoW that is..</p>
<p>So the above modification will reduce the number materialized entities from 1 000 001 to 1 (we materialize a double in this case)</p>
<p>I don&#8217;t know about you , but I&#8217;d rather clutter my domain logic slightly and get a million times better performance than stay true to POCO and suffer from a broken app.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/977/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/977/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/977/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=977&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/01/or-mapping-and-domain-query-optimizations/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>UoW / NWorkspace with Linq support</title>
		<link>http://rogeralsing.com/2011/03/18/uow-nworkspace-with-linq-support/</link>
		<comments>http://rogeralsing.com/2011/03/18/uow-nworkspace-with-linq-support/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 13:08:27 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Linq]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=974</guid>
		<description><![CDATA[I have blogged about this for quite a while now. Now I&#8217;ve finally cleaned up the code and published it at github:https://github.com/rogeralsing/Precio.Infrastructure This is a small framework for UoW/Workspace support in .NET with Linq support. The framework contains a Unit &#8230; <a href="http://rogeralsing.com/2011/03/18/uow-nworkspace-with-linq-support/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=974&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have blogged about this for quite a while now.<br />
Now I&#8217;ve finally cleaned up the code and published it at github:<a href="https://github.com/rogeralsing/Precio.Infrastructure">https://github.com/rogeralsing/Precio.Infrastructure</a></p>
<p>This is a small framework for UoW/Workspace support in .NET with Linq support.</p>
<p>The framework contains a Unit of Work implementation and providers for Entity Framework 4, NHibernate and MongoDB(using NoRM).<br />
There is also a small incomplete Blog sample project included.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/974/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/974/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/974/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=974&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/03/18/uow-nworkspace-with-linq-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Linq to SqlXml &#8211; GitHub</title>
		<link>http://rogeralsing.com/2011/03/02/linq-to-sqlxml-github/</link>
		<comments>http://rogeralsing.com/2011/03/02/linq-to-sqlxml-github/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 19:37:50 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq to SqlXml]]></category>
		<category><![CDATA[documentdb]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[ravendb]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Xquery]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=969</guid>
		<description><![CDATA[An early alpha of Linq to SqlXml is now available on github: https://github.com/calyptus/linq-to-sqlxml There is no documentation nor setup scripts so you&#8217;re on your own if you try it. If you get it to run, be sure to add all &#8230; <a href="http://rogeralsing.com/2011/03/02/linq-to-sqlxml-github/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=969&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An early alpha of Linq to SqlXml is now available on github: <a href="https://github.com/calyptus/linq-to-sqlxml">https://github.com/calyptus/linq-to-sqlxml</a></p>
<p>There is no documentation nor setup scripts so you&#8217;re on your own if you try it.<br />
If you get it to run, be sure to add all indexes to the xml field &#8211; primary , secondary &#8211; path , secondary &#8211; value , secondary &#8211; property</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/969/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=969&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/03/02/linq-to-sqlxml-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Linq to SqlXml: Projections</title>
		<link>http://rogeralsing.com/2011/03/02/linq-to-sqlxml-projections/</link>
		<comments>http://rogeralsing.com/2011/03/02/linq-to-sqlxml-projections/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 12:53:51 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=966</guid>
		<description><![CDATA[I&#8217;ve managed to add projection support to my Linq to Sql Server Xml column implementation. Executing this Linq query: Will yeild this Sql + XQuery:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=966&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve managed to add projection support to my Linq to Sql Server Xml column implementation.</p>
<p>Executing this Linq query:</p>
<p><pre class="brush: csharp;">
var query = (from order in ctx.GetCollection().AsQueryable()
                where order.OrderTotal &gt; 100000000
                where order.ShippingDate == null
                where order.OrderDetails.Sum(d =&gt; d.Quantity * d.ItemPrice) &gt; 10
                select new
                {
                    OrderTotal = order.OrderDetails.Sum(d =&gt; d.ItemPrice * d.Quantity),
                    CustomerId = order.CustomerId ,
                    Details = order.OrderDetails
                })
                .Take(5);
</pre></p>
<p>Will yeild this Sql + XQuery:</p>
<p><pre class="brush: sql;">select top 5 Id,DocumentData.query(
'&lt;object type=&quot;dynamic&quot;&gt;
 &lt;state&gt;
  &lt;OrderTotal type=&quot;decimal&quot;&gt;
   {fn:sum( 
              for $A in /object[1]/state[1]/OrderDetails[1]/object/state[1] 
                      return ($A/ItemPrice[1] * $A/Quantity[1]))}  &lt;/OrderTotal&gt;
  &lt;CustomerId type=&quot;guid&quot;&gt;
   {xs:string(/object[1]/state[1]/CustomerId[1])}
  &lt;/CustomerId&gt;
  &lt;Details type=&quot;collection&quot;&gt;
   {/object[1]/state[1]/OrderDetails[1]/object}
  &lt;/Details&gt;
 &lt;/state&gt;
&lt;/object&gt;') as DocumentData

from documents
where
CollectionName = 'Order'  and
(documentdata.exist('

/object/state[(fn:sum( 
        for $A in /object[1]/state[1]/OrderDetails[1]/object/state 
             return ($A/Quantity[1] * $A/ItemPrice[1])) &gt; xs:decimal(10)) and

/object[1]/state[1]/ShippingDate[1][@type=&quot;null&quot;] and
(/object[1]/state[1]/OrderTotal[1] &gt; xs:decimal(100000000))]

')) = 1

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rogeralsing.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rogeralsing.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rogeralsing.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rogeralsing.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rogeralsing.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rogeralsing.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rogeralsing.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rogeralsing.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rogeralsing.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rogeralsing.wordpress.com/966/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rogeralsing.wordpress.com/966/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rogeralsing.wordpress.com/966/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=966&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/03/02/linq-to-sqlxml-projections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
