<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3169527421400994472</id><updated>2012-02-16T10:38:24.118-08:00</updated><title type='text'>Doug Lim's Weblog</title><subtitle type='html'>Blogging about ASP .NET and .NET 3.5, MOSS 2007, WSS 3.0, Web Services, WCF, WPF, WF, LINQ, AJAX, SQL Server, CAML, XAML and all things .NET</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3169527421400994472.post-1503583779479208922</id><published>2011-09-04T10:20:00.001-07:00</published><updated>2011-09-04T10:20:44.644-07:00</updated><title type='text'>I'm back</title><content type='html'>Hey guys&lt;br /&gt;&lt;br /&gt;It's been a long time between drinks for me. But now I'm back ready to blog all things .NET and especially C#. Although my focus has changed somewhat, I like to leverage my time now. So I use a lot of great tools that makes my life much easier!&lt;br /&gt;&lt;br /&gt;Anyway be prepared to get some real cool .NET posts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3169527421400994472-1503583779479208922?l=duggiel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/1503583779479208922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3169527421400994472&amp;postID=1503583779479208922' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/1503583779479208922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/1503583779479208922'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/2011/09/im-back.html' title='I&apos;m back'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3169527421400994472.post-8139583910200084823</id><published>2008-02-08T07:18:00.000-08:00</published><updated>2008-02-08T08:47:59.358-08:00</updated><title type='text'>Using Datagrids in the Compact Framework 2.0</title><content type='html'>Datagrids in Winforms apps are similar to Gridviews in web apps. However there are some intricacies when dealing with datagrids in mobile apps using the Compact Framework 2.0 SP1. Here's a quick example of how to do it using an arraylist as the datasource:&lt;br /&gt;&lt;br /&gt;1. The columns of the datagrid must correspond to public properties of the binding class. That is, the class type of each object in the arraylist.&lt;br /&gt;2. Use a BindingList&lt;item&gt; (&lt;a href="http://msdn2.microsoft.com/en-us/library/ms132679(VS.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms132679(VS.80).aspx&lt;/a&gt;) instead of an ArrayList.&lt;br /&gt;3. Use the CurrencyManager class to perform operations on the datagrid such as refreshing the datagrid once the underlying arraylist datasource has been modified.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3169527421400994472-8139583910200084823?l=duggiel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/8139583910200084823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3169527421400994472&amp;postID=8139583910200084823' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/8139583910200084823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/8139583910200084823'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/2008/02/using-datagrids-in-compact-framework-20.html' title='Using Datagrids in the Compact Framework 2.0'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3169527421400994472.post-7898683672048164769</id><published>2008-01-06T05:13:00.000-08:00</published><updated>2008-01-06T07:32:41.874-08:00</updated><title type='text'>Ruby on Rails and ASP .NET</title><content type='html'>There are so many different languages that can be used to develop a web application. To name a few: Ruby, PHP, ASP .NET, ASP, HTML, XML and XSLT, Python, Perl, Javascript, and the list goes on. I've been developing web apps using ASP .NET to the point now where I can knock up a database driven site in a few hours top. So you could say I'm biased and a huge fan of ASP .NET.&lt;br /&gt;&lt;br /&gt;However, recently I've been looking at Ruby on Rails and have to admit I'm quite impressed with the open source web framework. Ruby is a pure object oriented language whilst Rails is a web framework for developing web based database driven sites. Hence, put the two together and we have Ruby on Rails - an object oriented language for quickly developing web based database driven sites.&lt;br /&gt;&lt;br /&gt;Ruby on Rails uses the MVC pattern (&lt;a href="http://en.wikipedia.org/wiki/Model-view-controller"&gt;http://en.wikipedia.org/wiki/Model-view-controller&lt;/a&gt;) with models that wrap and model the underlying data from the database, views for displaying this data and controllers serving the user's page request. Rails automatically creates a directory structured based on MVC and with a bit of plumbing, a database driven site is ready to go within minutes!&lt;br /&gt;&lt;br /&gt;And it's only recently that Microsoft (&lt;a href="http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx&lt;/a&gt;) has answered the calls of many people and released built in support for ASP .NET that allow web apps to be built using the MVC framework.&lt;br /&gt;&lt;br /&gt;Some pluses of Ruby on Rails is that it's fully open source, integrates well with MySQL (another open source database) and the real benefit comes when Rails creates your create, read, update and delete (CRUD) database operations for you saving time as a developer (just like using an ORM such as NHibernate or LINQ to SQL with ASP .NET). Some downsides are that it doesn't integrate well with SQL Server 2005 even though there is an adapter for it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3169527421400994472-7898683672048164769?l=duggiel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/7898683672048164769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3169527421400994472&amp;postID=7898683672048164769' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/7898683672048164769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/7898683672048164769'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/2008/01/ruby-on-rails-and-asp-net.html' title='Ruby on Rails and ASP .NET'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3169527421400994472.post-6893402744482907161</id><published>2008-01-01T21:50:00.000-08:00</published><updated>2008-01-01T22:10:59.303-08:00</updated><title type='text'>Database Synchronization Tools</title><content type='html'>I recently played around with a nifty new tool from Perpetuum software called Database Restyle, found here (&lt;a href="http://www.perpetuumsoft.com/Product.aspx?lang=en&amp;amp;pid=55"&gt;http://www.perpetuumsoft.com/Product.aspx?lang=en&amp;amp;pid=55&lt;/a&gt;). Slightly different to what I'm use to due to the fact that to synch your live database with your developer database it is not an external application per se.&lt;br /&gt;&lt;br /&gt;You can actually integrate Database Restyle as a component within your code, or you can use it to develop a stand alone application in itself. This makes it extremely handy during deployment. The other thing I liked about it is that it supports LINQ to SQL data models and it's written in .NET 2.0.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3169527421400994472-6893402744482907161?l=duggiel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/6893402744482907161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3169527421400994472&amp;postID=6893402744482907161' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/6893402744482907161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/6893402744482907161'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/2008/01/database-synchronization-tools.html' title='Database Synchronization Tools'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3169527421400994472.post-2134756070787608359</id><published>2007-12-27T22:06:00.000-08:00</published><updated>2007-12-28T01:23:35.546-08:00</updated><title type='text'>New C# 3.0 Language Features</title><content type='html'>&lt;span style="color:#000000;"&gt;One of the issues I've always had as a developer is using language specific features that make my life easier. So I've spent the day playing with some of the new C# 3.0 language features. Here's what I've found  with some of the new features:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Implicitly Typed Local Variables&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;A new keyword&lt;/span&gt; &lt;strong&gt;var &lt;/strong&gt;&lt;span style="color:#000000;"&gt;now exists that you can use in place of a formal data type such as int, string etc. So instead of the following:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;string result = "Success";&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;int i = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;bool isCompleted = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;We can now do the following:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;var result = "Success";&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;var i = 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;var isCompleted = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;So how does the compiler know the underlying variable type? Simple, it looks at the initial value assigned to the variable. Note that implicitly typed local variables can also be used in a for or foreach statement as follows:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;var birthdays = new int[] { 5, 14, 24, 30 };&lt;br /&gt;foreach (var birthday in birthdays)&lt;br /&gt;{&lt;br /&gt;// Do something here&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Some caveats to note:&lt;br /&gt;1. As you may have already worked out, variables declared using var must have an initial value assigned and cannot be assigned &lt;em&gt;null&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;2. Implicitly typed local variables, as the name suggests, is restricted to local method or property variables only. It cannot be used for global variables and return values.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;So what's the major advantage of using implicitly typed local variables? LINQ! (I'll blog on this later). But if you're not using LINQ, it's far better to declare the variable type explicitly rather than using var since it makes it much easier to read and to understand the code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;strong&gt;Lambda Expressions&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Anonymous methods (Found in C# 2.0 whereby inline code can be used to define a delegate rather than a standalone function in itself) can now be rewritten using a much more simplified syntax. So instead of the following:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;&lt;br /&gt;List&lt;int&gt; numbers = new List&lt;int&gt;();&lt;br /&gt;numbers.AddRange(new int[] { 1,2,3,4,5,6,7,8,9,10,11,12 } );&lt;br /&gt;&lt;br /&gt;List&lt;int&gt; even = numbers.FindAll(delegate(int i) { return (i % 2) == 0; });&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;We can write:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#3366ff;"&gt;List&lt;int&gt; even = numbers.FindAll(i =&gt; (i % 2) == 0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once again, this is primed to be useful in LINQ.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Object Initializers&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;We are now able to initialize a new object and set its property values in one statement. So before we had:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;CreditCard cc = new CreditCard();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;cc.CardName = "John Smith";&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;cc.CardNumber = "1324234234";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;But now we can simply rewrite this into one single statement as follows:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;CreditCard cc = new CreditCard&lt;/span&gt; &lt;span style="color:#3366ff;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;       CardName = "John Smith",&lt;br /&gt;       CardNumber = "1324234234"&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;color:#666666;"&gt;Extension Methods&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;This is a major new change. We are now able to inject new functionality into a compiled type (such as adding new methods) without having to touch the already compiled assembly. So for example, we can add a new method to the string type to determine if the string assigned contains the keyword "Hello". See below:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;public static class StringExtension{   &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;    public static bool ContainsHello(this string s)  &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   {      &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;         return s.Contains("Hello");   &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;}  &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;class Example&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;      public static void Main(string[] args)   &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;     {    &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;           string s = "Hello world";     &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;           bool result = s.ContainsHello();             &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;      }&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;As you've probably already noticed, extensions methods can only be declared in static classes. Likewise, an extension method is declared when the &lt;strong&gt;this &lt;/strong&gt;keyword is placed in front of the first parameter. It is assumed that the first parameter will be the one that is extended. You may have multiple parameters in an extension method, however the &lt;strong&gt;this&lt;/strong&gt; keyword can only be applied to the first parameter.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Automatic Properties&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;I've always found it really annoying writing verbose properties throughout my code, even if I'm using Visual Studio's code snippet. So now instead of writing:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;private string address = String.Empty;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;public string Address&lt;br /&gt;{&lt;br /&gt;    get &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   { &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;         return address; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   } &lt;br /&gt;   set &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   { &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;         address = value; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;We can now write the following:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;public string Address { get; set; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Notice that if we wanted to override this property, we would need to add the abstract keyword in front of the property.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Caveats associated with this are:&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;1. Both get and set properties must be set. You cannot simply make it read only.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;2. However, we can set different visibility modifiers for the get and set properties. For example, the read only property can be restricted to classes within the assembly only while the write property can be public.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Anonymous Types&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;At compile time, anonymous types now allow us to create a type on the fly. For example, instead of writing:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;class Address &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;{&lt;br /&gt;    private int number;&lt;br /&gt;    private string street;&lt;br /&gt;&lt;br /&gt;    public int Number &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   {&lt;br /&gt;      get &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;     {&lt;br /&gt;          return number; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;     }&lt;br /&gt;     set &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;     { &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;          number = value; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;    public string Street&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;   {&lt;br /&gt;      get &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;      { &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;           return street; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;      }&lt;br /&gt;      set &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;      {&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;          street = value; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Address address = new Address();&lt;br /&gt;address.Number = 14;&lt;br /&gt;address.Street = "Flinders St";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;We can now write:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;var anonymousType = new {Number = 14, Street = "Flinders St"};&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#000000;"&gt;Note that anonymous types must be declared using the&lt;/span&gt; &lt;strong&gt;var &lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;keyword.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3169527421400994472-2134756070787608359?l=duggiel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/2134756070787608359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3169527421400994472&amp;postID=2134756070787608359' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/2134756070787608359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/2134756070787608359'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/2007/12/new-c-30-language-features.html' title='New C# 3.0 Language Features'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3169527421400994472.post-6996423499748576867</id><published>2007-12-12T06:18:00.000-08:00</published><updated>2007-12-12T06:49:39.398-08:00</updated><title type='text'>Web Application Design in ASP .NET 2.0 and 3.5</title><content type='html'>Well I've been developing web applications in ASP .NET for quite a while now and some good practices to follow when designing your web application come to mind:&lt;br /&gt;&lt;br /&gt;1. Always separate your web application out into nice clean loosely coupled layers. At a bare minimum, separate your data access logic into a data access layer/persistence facade, your business logic (handling verification and manipulation of data) into a business logic layer and your UI into its own web forms.&lt;br /&gt;&lt;br /&gt;Scott Guthrie and his team have just released ASP .NET 3.5 extensions which allows web applications to be developed using a MVC approach compared to the normal page lifecycle/view state approach. This makes it a lot easier for Test Driven Development (TDD) and an extremely clean separation of the above 3 layers. I'll blog on this later when I use this approach for a client.&lt;br /&gt;&lt;br /&gt;2. View state!! Remember server side control information is stored in view state which is sent from the server to the browser and back again allowing the control's state to be retained after a postback. So if you jam pack your page with server-side controls, your view state is going to get very large and this will impact performance. So use client side controls (good old HTML) where possible especially if the control is not going to be changed. eg. label&lt;br /&gt;&lt;br /&gt;3. Make use of the wonderful features that ASP .NET 2.0 provides over 1.1. Such as master pages and themes for enabling a consistent look and feel across the web site. Dream weaver used templates to incorporate this behaviour. Having used it myself, consider yourself lucky!&lt;br /&gt;&lt;br /&gt;4. If there are multiple sections in a master page, create user controls (.ascx). This provides finer granularity of control in your code behind.&lt;br /&gt;&lt;br /&gt;5. In your data access layer ensure you use parameterized SQL queries or parameterized stored procedures or an ORM to avoid SQL injection attacks.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3169527421400994472-6996423499748576867?l=duggiel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/6996423499748576867/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3169527421400994472&amp;postID=6996423499748576867' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/6996423499748576867'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/6996423499748576867'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/2007/12/web-application-design-in-asp.html' title='Web Application Design in ASP .NET 2.0 and 3.5'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3169527421400994472.post-9096630848395300094</id><published>2007-11-17T04:08:00.000-08:00</published><updated>2007-12-12T06:18:09.206-08:00</updated><title type='text'>Designing a Web Service</title><content type='html'>Whilst working for a client the other day, I had to write a web service with a couple web methods. Reading a lot of blogs on the subject and what people try and achieve with web services, there are some important points to consider when designing a web service and its web methods in .NET. They are:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Remember that web services according to WS-I (Web Services Interoperability) must be interoperable with different platforms such as .NET and Java. So do not use language specific types such as an arraylist in C#. Java won't understand this. Use an array instead.&lt;br /&gt;&lt;br /&gt;2. Web services are inherently stateless. If you are finding yourself needing to store state information, then it is highly likely that you should revisit your web service design. Nevertheless, if you need to maintain state in .NET, use a CookieContainer on the client proxy to send back the same session details to the web method.  ASP .NET will then be able to find the right session state object. And you will need to add the [WebMethod(EnableSession=true)] attribute to your web method.&lt;br /&gt;&lt;br /&gt;Note that if you are using the compact framework (as of 2.1), you will have to override the GetWebRequest and GetWebResponse methods to send back the session details.&lt;br /&gt;&lt;br /&gt;3. Return a useful response message back to the user if something fails. It's so obvious but yet so frustrating to call a web service, only for something to fail and no response message given.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3169527421400994472-9096630848395300094?l=duggiel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://duggiel.blogspot.com/feeds/9096630848395300094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3169527421400994472&amp;postID=9096630848395300094' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/9096630848395300094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3169527421400994472/posts/default/9096630848395300094'/><link rel='alternate' type='text/html' href='http://duggiel.blogspot.com/2007/11/designing-web-service.html' title='Designing a Web Service'/><author><name>Doug</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
