Linq in

A quick sample of how to use linq in your webpages



<% Model.ToList().ForEach(item =>
{ %>
          <%: Html.ActionLink("Edit", "Edit", new { id = item.AlbumId })%> |
          <%: Html.ActionLink("Delete", "Delete", new { id = item.AlbumId })%>
      <td><%: Html.Truncate(item.Title, 25)%></td>
      <td><%: Html.Truncate(item.Artist.Name, 25)%></td>
      <td><%: item.Genre.Name%></td>
<% }); %>



I said quick ey!  :-)

Workflow Arguments how to

So you've started up your very first 4.0 Workflow application.
You've added some arguments and want to know how to pass some information..
You can either use the Dictionary approach that exists since 3.0 or you can use the properites you've just created.


Thes scrren shots show a simple workflow with an input string UserName and an output string Greeting.




I added an assignment activity and set the "To" to be the output Arguement "Greeting"


And set the Value as follows.



To prove this works I've added a test fixture and implemented it as follows




So there you go. The quickie for today Smile

Syncronization Context

A sample of using SyncronizationContext to post a message back to the UX thread



private void Window_Loaded(object sender, RoutedEventArgs e)
    SynchronizationContext ctx = SynchronizationContext.Current;

    ThreadPool.QueueUserWorkItem(_ =>

        WebClient client = new WebClient();

        string html = client.DownloadString("");
        ctx.Post(state =>
            tbDetails.Text = (string)state;

        }, html);




MVC Stories

Hi All,

Been a while since I've writen some posts, been pretty hectic hours at work and weekends building a house so my chances to blog have been limited.

I intend over the coming few days to give a few tips and tricks on MCV2.

Here's on gottya..

Be carefull how you name your formal arguements in your controller functions.

You can see from the screenshot below that I created two args, "Name" and "name"

By default the first matching case insensitive value will be applied to both variables by MVC...

Usually this will be avoided by good naming conventions but be carefull nonetheless :-)