<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>C#</title>
        <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/category/30.aspx</link>
        <description>C#</description>
        <language>en-US</language>
        <copyright>Shawn Weisfeld</copyright>
        <generator>Subtext Version 2.1.2.2</generator>
        <item>
            <title>Using C# 4.0 and dynamic to parse JSON</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/08/22/using-c-4.0-and-dynamic-to-parse-json.aspx</link>
            <description>&lt;p&gt;I recently had to get a JSON feed from the web and traverse it. Like any good developer I started off with a Bing search and stumbled across a few posts. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;The first by Nikhil Kothari looked interesting but his implementation did way too much, all I needed to do was read a JSON file, did I really need all that code. &lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.nikhilk.net/CSharp-Dynamic-Programming-JSON.aspx" href="http://www.nikhilk.net/CSharp-Dynamic-Programming-JSON.aspx"&gt;http://www.nikhilk.net/CSharp-Dynamic-Programming-JSON.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;The second post I saw by Alex Ghiondea again looked interesting but relied on a library from codeplex (JSON.NET, &lt;a title="http://json.codeplex.com/" href="http://json.codeplex.com/"&gt;http://json.codeplex.com/&lt;/a&gt;) and again I thought this was a bit overkill for my project. &lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/b/alexghi/archive/2008/12/22/using-anonymous-types-to-deserialize-json-data.aspx" href="http://blogs.msdn.com/b/alexghi/archive/2008/12/22/using-anonymous-types-to-deserialize-json-data.aspx"&gt;http://blogs.msdn.com/b/alexghi/archive/2008/12/22/using-anonymous-types-to-deserialize-json-data.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;But Nikhil’s post did get me thinking that this might be a good place to use the new dynamic “type” in C# 4.0. With some further research I dug up that in .NET 3.5 we got a new class called the JavaScriptSerializer, MSDN describes it as:&lt;/p&gt;  &lt;p&gt;The JavaScriptSerializer class is used internally by the asynchronous communication layer to serialize and deserialize the data that is passed between the browser and the Web server. You cannot access that instance of the serializer. However, this class exposes a public API. Therefore, you can use the class when you want to work with JavaScript Object Notation (JSON) in managed code.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer(v=VS.100).aspx" href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer(v=VS.100).aspx"&gt;http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer(v=VS.100).aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;To use the JavaScriptSerializer (from the System.Web.Extensions dll) you have to implement a JavaScriptConverter. I can do that. :) After poking around a bit with the JavaScriptSerializer I realized that it gives you a few things. A value, an array list of values, a dictionary of key value pairs, or an ArrayList containing an array of dictionary of key value pairs. What I want to do is if I see a dictionary I want my user to be able to use the key as a property on my dynamic, if I see an ArrayList I want the user to be able to iterate over the collection and see its members, finally if I see a value I want to just return it. &lt;/p&gt;  &lt;p&gt;Lets start with a simple JSON file, that I borrowed from json.org:&lt;/p&gt;  &lt;p&gt;{   &lt;br /&gt;    "glossary": {    &lt;br /&gt;        "title": "example glossary",    &lt;br /&gt;        "GlossDiv": {    &lt;br /&gt;            "title": "S",    &lt;br /&gt;            "GlossList": {    &lt;br /&gt;                "GlossEntry": {    &lt;br /&gt;                    "ID": "SGML",    &lt;br /&gt;                    "SortAs": "SGML",    &lt;br /&gt;                    "GlossTerm": "Standard Generalized Markup Language",    &lt;br /&gt;                    "Acronym": "SGML",    &lt;br /&gt;                    "Abbrev": "ISO 8879:1986",    &lt;br /&gt;                    "GlossDef": {    &lt;br /&gt;                        "para": "A meta-markup language, used to create markup languages such as DocBook.",    &lt;br /&gt;                        "GlossSeeAlso": ["GML", "XML"]    &lt;br /&gt;                    },    &lt;br /&gt;                    "GlossSee": "markup"    &lt;br /&gt;                }    &lt;br /&gt;            }    &lt;br /&gt;        }    &lt;br /&gt;    }    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.json.org/example.html" href="http://www.json.org/example.html"&gt;http://www.json.org/example.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;So with this the above JSON I want to be able to write “glossaryEntry.glossary.title” or “glossaryEntry.glossary.GlossDiv.GlossList.GlossEntry.ID” and get back “example glossary” and “SGML” respectively. All without having to actually create a static “glossary” object.&lt;/p&gt;  &lt;p&gt;So the first step is to create our DynamicObject. I called mine DynamicJsonObject and as you can see it inherits from the base DynamicObject class.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;pre style="font-family: consolas"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DynamicJsonObject&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;DynamicObject&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt; Dictionary { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; DynamicJsonObject(&lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt; dictionary)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.Dictionary = dictionary;&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;bool&lt;/span&gt; TryGetMember(&lt;span style="color: #2b91af"&gt;GetMemberBinder&lt;/span&gt; binder, &lt;span style="color: blue"&gt;out&lt;/span&gt; &lt;span style="color: blue"&gt;object&lt;/span&gt; result)&lt;br /&gt;    {&lt;br /&gt;        result = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Dictionary[binder.Name];&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue"&gt;if&lt;/span&gt; (result &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;)&lt;br /&gt;        {&lt;br /&gt;            result = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DynamicJsonObject&lt;/span&gt;(result &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (result &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArrayList&lt;/span&gt; &amp;amp;&amp;amp; (result &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArrayList&lt;/span&gt;) &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;)&lt;br /&gt;        {&lt;br /&gt;            result = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;DynamicJsonObject&lt;/span&gt;&amp;gt;((result &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArrayList&lt;/span&gt;).ToArray().Select(x =&amp;gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DynamicJsonObject&lt;/span&gt;(x &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;)));&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (result &lt;span style="color: blue"&gt;is&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArrayList&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            result = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;((result &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArrayList&lt;/span&gt;).ToArray());&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Dictionary.ContainsKey(binder.Name);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

&lt;p&gt;The tricky bit is in the “TryGetMember” Method. The binder.Name is the property value you used in your code. As you can see I am looking that guy up in the current internal dictionary. I then test its type. If it is a dictionary, I wrap it in another DynamicJsonObject and give it back. If it is an ArrayList of Dictionaries then I wrap each item as an DynamicJsonObject and send back the List. If it is just an Array List I convert it to a List and send it back. Finally we have to tell .NET if we found it at all. &lt;/p&gt;

&lt;p&gt;The only other thing we need is an implementation of the JavaScriptConverter.&lt;/p&gt;

&lt;pre style="font-family: consolas"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DynamicJsonConverter&lt;/span&gt; : &lt;span style="color: #2b91af"&gt;JavaScriptConverter&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: blue"&gt;object&lt;/span&gt; Deserialize(&lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt; dictionary, &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt; type, &lt;span style="color: #2b91af"&gt;JavaScriptSerializer&lt;/span&gt; serializer)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;if&lt;/span&gt; (dictionary == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;                &lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"dictionary"&lt;/span&gt;);&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: blue"&gt;if&lt;/span&gt; (type == &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;object&lt;/span&gt;))&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DynamicJsonObject&lt;/span&gt;(dictionary);&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt; Serialize(&lt;span style="color: blue"&gt;object&lt;/span&gt; obj, &lt;span style="color: #2b91af"&gt;JavaScriptSerializer&lt;/span&gt; serializer)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;NotImplementedException&lt;/span&gt;();&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;&amp;gt; SupportedTypes&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ReadOnlyCollection&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;&amp;gt;(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;&amp;gt;(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;[] { &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;object&lt;/span&gt;) })); }&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;

&lt;p&gt;As you can see by the above code we are only supporting the deserialize method, and the only thing we do is wrap the dictionary with our DynamicJsonObject. Finally since we are using dynamic we can support any object type with this converter.&lt;/p&gt;

&lt;p&gt;Now for the fun bit, lets use it. &lt;/p&gt;

&lt;pre style="font-family: consolas"&gt;            &lt;span style="color: #2b91af"&gt;JavaScriptSerializer&lt;/span&gt; jss = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;JavaScriptSerializer&lt;/span&gt;();&lt;br /&gt;            jss.RegisterConverters(&lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;JavaScriptConverter&lt;/span&gt;[] { &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DynamicJsonConverter&lt;/span&gt;() });&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: blue"&gt;dynamic&lt;/span&gt; glossaryEntry = jss.Deserialize(json, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;object&lt;/span&gt;)) &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: blue"&gt;dynamic&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"glossaryEntry.glossary.title: "&lt;/span&gt; + glossaryEntry.glossary.title);&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"glossaryEntry.glossary.GlossDiv.title: "&lt;/span&gt; + glossaryEntry.glossary.GlossDiv.title);&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"glossaryEntry.glossary.GlossDiv.GlossList.GlossEntry.ID: "&lt;/span&gt; + glossaryEntry.glossary.GlossDiv.GlossList.GlossEntry.ID);&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"glossaryEntry.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.para: "&lt;/span&gt; + glossaryEntry.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.para);&lt;br /&gt;            &lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: blue"&gt;var&lt;/span&gt; also &lt;span style="color: blue"&gt;in&lt;/span&gt; glossaryEntry.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"glossaryEntry.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso: "&lt;/span&gt; + also);&lt;br /&gt;            }&lt;/pre&gt;

&lt;p&gt;To use our converter we create a serializer, register our converter with it and then call the deserialize method. Now we can use our standard “dot” notation to traverse our JSON object without the need for external libraries and in under 100 lines of code. Now JSON in .NET feels a lot like JSON in JavaScript. . . When I heard that C# was getting this dynamic stuff I was unsure of its power and relevance, now I have “seen the light” and can really see where this was a great addition to the language. &lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/763.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Weisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/08/22/using-c-4.0-and-dynamic-to-parse-json.aspx</guid>
            <pubDate>Sun, 22 Aug 2010 13:03:32 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/763.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/08/22/using-c-4.0-and-dynamic-to-parse-json.aspx#feedback</comments>
            <slash:comments>19</slash:comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/763.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/763.aspx</trackback:ping>
        </item>
        <item>
            <title>Developer&lt;T&gt;: Utilizing .NET Generics to write better code by Shawn Weisfeld @ UT Dallas .NET UG on 02/27/2010</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/02/24/developert-utilizing-.net-generics-to-write-better-code-by-shawn.aspx</link>
            <description>&lt;p&gt;This Saturday (2/27) I will be giving my .NET Generics talk for the UT Dallas .NET UG in Richardson TX. If you are in the area please check it out (&lt;a href="http://www.usergroupsupportservices.com/UGEventView.ugss?EventID=9160"&gt;http://www.usergroupsupportservices.com/UGEventView.ugss?EventID=9160&lt;/a&gt;). If you cannot make it but are interested in seeing the talk, you can watch it online.&lt;/p&gt;
&lt;p&gt;&lt;embed height="300" type="application/x-shockwave-flash" width="400" src="http://blip.tv/play/hYpfgb_iWgA" allowfullscreen="true" allowscriptaccess="always" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Abstract:&lt;/strong&gt;&lt;br /&gt;
Generics let you tailor a method, class, structure, or interface to the precise data type it acts upon. In this session we will discuss what capabilities Generics provide to you the developer and how to use them in collections, and with delegates. We will also talk about creating your own generic classes and methods.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Download&lt;/strong&gt; &lt;br /&gt;
&lt;a href="http://www.developerroundtable.com/Libraries/Misc_Stuff/2009HustonTechFestGenerics.sflb.ashx?download=true"&gt;PowerPoint &amp;amp; Demos&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bio:&lt;/strong&gt;&lt;br /&gt;
Shawn Weisfeld (shawn@shawnweisfeld.com) is a Staff Developer at a fortune 100 company, currently located at Dallas TX facility. There he specializes in intranet &amp;amp; smart client development for internal line of business applications. Besides his day job Shawn also is an Adjunct Professor at The Florida Institute of Technology (http://www.fit.edu). He also does freelance software development work for local small businesses and training. In his free time he volunteers with INETA NorAm (http://www.ineta.org) and is a member of the Board of Directors and Mentor for North Texas. Shawn started his career at his family business in Port St. Lucie FL while working on his undergraduate degree in Business Administration at the University of Central Florida and after a year off Shawn moved back to Orlando to pursue a Masters degree in Management Information Systems at The University of Central Florida and has since earned a second Masters degree in Computer Information Systems from Florida Institute of Technology. Shawn was awarded the Microsoft C# Most Valuable Professional award for 2007 - 2010. Shawn is an avid technology presenter and since July of 2005 Shawn has presented at many user group events, and even got to speak at the launch of Visual Studio. Shawn has served as the President of the Orlando .NET UG (http://www.onetug.org) from 2006 – 2008, and started the Developer Round Table UG (http://www.developerroundtable.com) in 2009. Shawn regularly attends, and records for INETA LIVE (http://live.ineta.org), many of the local user groups in the D/FW metroplex, including; D/FW Connected Systems UG, Dallas .NET UG, Dallas ASP.NET UG, Dallas C# Programming Sig, Dallas VSTS UG, North Dallas .NET UG, North Texas PC UG, UT Dallas .NET UG.  So be sure to say hello if you see him.&lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/677.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Weisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/02/24/developert-utilizing-.net-generics-to-write-better-code-by-shawn.aspx</guid>
            <pubDate>Thu, 25 Feb 2010 01:45:54 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/677.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2010/02/24/developert-utilizing-.net-generics-to-write-better-code-by-shawn.aspx#feedback</comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/677.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/677.aspx</trackback:ping>
        </item>
        <item>
            <title>Shawn @ Dallas Dev Cares 2009/12/11</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/12/12/shawn-dallas-dev-cares-20091211.aspx</link>
            <description>&lt;p&gt;Thanks to all that attended my 3 talks at the Dallas Dev Cares UG yesterday and thanks Ken Byrd from TekFocus for hosting the meeting. As promised here is the download of the PowerPoint and code bits. I also included links to recordings of 2 of the 3 talks. &lt;/p&gt;
&lt;p&gt;&lt;a title="Download" href="http://www.developerroundtable.com/Libraries/Misc_Stuff/20091211_DevCares.sflb.ashx?download=true"&gt;Download Presentations Here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Recording of ASP.NET Dynamic Data:&lt;/p&gt;
&lt;div&gt;&lt;embed src="http://blip.tv/play/hYpfgb_3NwA" type="application/x-shockwave-flash" width="400" height="300" allowscriptaccess="always" allowfullscreen="true" /&gt;&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Recording of Developer of &amp;lt;T&amp;gt; Generics talk:&lt;/p&gt;
&lt;div&gt;&lt;embed src="http://blip.tv/play/hYpfgb_iWgA" type="application/x-shockwave-flash" width="400" height="300" allowscriptaccess="always" allowfullscreen="true" /&gt;&lt;/div&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/646.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Weisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/12/12/shawn-dallas-dev-cares-20091211.aspx</guid>
            <pubDate>Sat, 12 Dec 2009 16:10:00 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/646.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/12/12/shawn-dallas-dev-cares-20091211.aspx#feedback</comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/646.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/646.aspx</trackback:ping>
        </item>
        <item>
            <title>Dallas DevCares &amp;ndash; Dec 11 2009: C# Generics, ASP.NET Dynamic Data &amp;amp; VS.NET Tips and Tricks</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/11/10/dallas-devcares-ndash-dec-11-2009-c-generics-asp.net-dynamic.aspx</link>
            <description>&lt;p&gt;By popular request on Dec 11 I will be giving 2 of my most popular talks on C# Generics and ASP.NET Dynamic Data. Then as a bonus just for the DevCares Community I will put together some of my favorite VS.NET Tips and Tricks. You can attend online or in person. Get all the details on there website at &lt;a title="http://www.dallasdevcares.com/" href="http://www.dallasdevcares.com/"&gt;http://www.dallasdevcares.com/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/567.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Weisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/11/10/dallas-devcares-ndash-dec-11-2009-c-generics-asp.net-dynamic.aspx</guid>
            <pubDate>Tue, 10 Nov 2009 12:43:44 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/567.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/11/10/dallas-devcares-ndash-dec-11-2009-c-generics-asp.net-dynamic.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/567.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/567.aspx</trackback:ping>
        </item>
        <item>
            <title>Tulsa Tech Fest 2009</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/11/06/tulsa-tech-fest-2009.aspx</link>
            <description>&lt;div&gt;
&lt;div&gt;

&lt;embed src="http://blip.tv/play/hYpfgb_iWgA" type="application/x-shockwave-flash" width="400" height="300" allowscriptaccess="always" allowfullscreen="true" /&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;Thanks to everyone that attended my .NET Generics Talk at the Tulsa Tech Fest today. You can download the code and PowerPoint &lt;a href="http://www.developerroundtable.com/Libraries/Misc_Stuff/2009HustonTechFestGenerics.sflb.ashx?download=true"&gt;here&lt;/a&gt;, and the recording will be posted to this blog and &lt;a href="http://live.ineta.org"&gt;INETA Live&lt;/a&gt; shortly. &lt;/p&gt;
&lt;p&gt;Developer&amp;lt;T&amp;gt;: Utilizing .NET Generics to write better code &lt;/p&gt;
&lt;p&gt;Shawn Weisfeld &lt;/p&gt;
&lt;p&gt;Generics let you tailor a method, class, structure, or interface to the precise data type it acts upon. In this session we will discuss what capabilities Generics provide to you the developer and how to use them in collections, and with delegates. We will also talk about creating your own generic classes and methods. &lt;/p&gt;
&lt;p&gt;I wanted to thanks Scott Dorman author of the yet to be released &lt;a href="http://geekswithblogs.net/sdorman/archive/2009/06/26/sams-teach-yourself-c-2010-in-24-hours.aspx"&gt;Sams Teach Yourself C# 2010 in 24 Hours&lt;/a&gt;, for his help during the creation of this presentation.  &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/562.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Weisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/11/06/tulsa-tech-fest-2009.aspx</guid>
            <pubDate>Fri, 06 Nov 2009 15:37:36 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/562.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/11/06/tulsa-tech-fest-2009.aspx#feedback</comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/562.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/562.aspx</trackback:ping>
        </item>
        <item>
            <title>Call a Multiple-Rowset stored procedure with LINQ to SQL and without the designer</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/12/call-a-multiple-rowset-stored-procedure-with-linq-to-sql.aspx</link>
            <description>&lt;p&gt;Multiple-Rowset allows you to return more than one select from your stored procedure. For example in the stored procedure below you can see we have 2 select statements.&lt;/p&gt;  &lt;p&gt;&lt;a href="file:///C:\Users\Shawn\AppData\Local\Temp\WindowsLiveWriter1286139640\supfiles6309CCF7\image3.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image002_17D3F2F6.gif" width="551" height="547" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As we learned in my last 2 posts it is possible to use LINQ to SQL without the designer.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A simple select with LINQ to SQL and without the designer (&lt;a href="http://drowningintechnicaldebt.com/blogs/shawnweisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the-designer.aspx"&gt;http://drowningintechnicaldebt.com/blogs/shawnweisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the-designer.aspx&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;Call a stored procedure with LINQ to SQL and without the designer (&lt;a href="http://drowningintechnicaldebt.com/blogs/shawnweisfeld/archive/2009/07/11/call-a-stored-procedure-with-linq-to-sql-and-without-the-designer.aspx"&gt;http://drowningintechnicaldebt.com/blogs/shawnweisfeld/archive/2009/07/11/call-a-stored-procedure-with-linq-to-sql-and-without-the-designer.aspx&lt;/a&gt;) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To utilize Multiple-Rowset we just need to tweak our function in our data context a little. &lt;/p&gt;  &lt;p&gt;&lt;a href="file:///C:\Users\Shawn\AppData\Local\Temp\WindowsLiveWriter1286139640\supfiles6309CCF7\image15.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image004_3D5D7057.gif" width="775" height="344" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here you can see that we added 2 result type attributes. These map to our result sets. Since our stored procedure returns 2 result sets of customers we tell LINQ to SQL to mach each to the customer object. However if your stored procedure returns different types you can of course do that. We also changed our result type to that of IMultipleResults. This will allow us to pick off each of the result sets when we call our method.&lt;/p&gt;  &lt;p&gt;&lt;a href="file:///C:\Users\Shawn\AppData\Local\Temp\WindowsLiveWriter1286139640\supfiles6309CCF7\image11.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image006_638FA3E2.gif" width="785" height="278" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is the call to the method. You can see when we call “GetResult” the first time we get our first result set. Then when we call it a second time we get the second result set. &lt;/p&gt;  &lt;p&gt;&lt;a href="file:///C:\Users\Shawn\AppData\Local\Temp\WindowsLiveWriter1286139640\supfiles6309CCF7\image7.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image008_17579A34.gif" width="652" height="519" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That is it. &lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/314.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>sweisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/12/call-a-multiple-rowset-stored-procedure-with-linq-to-sql.aspx</guid>
            <pubDate>Sun, 12 Jul 2009 21:45:23 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/314.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/12/call-a-multiple-rowset-stored-procedure-with-linq-to-sql.aspx#feedback</comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/314.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/314.aspx</trackback:ping>
        </item>
        <item>
            <title>Call a stored procedure with LINQ to SQL and without the designer</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/11/call-a-stored-procedure-with-linq-to-sql-and-without.aspx</link>
            <description>&lt;p&gt;In my last post I talked about how to do a simple select with LINQ to SQL without the designer (&lt;a href="/blogs/shawnweisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the-designer.aspx" title="http://drowningintechnicaldebt.com/blogs/shawnweisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the-designer.aspx"&gt;http://drowningintechnicaldebt.com/blogs/shawnweisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the-designer.aspx&lt;/a&gt;). This is all well and good, but what if you need to use a stored procedure. Like this one. . . . &lt;/p&gt;
&lt;p&gt;&lt;a href="/shawnweisfeld/image_036499A1.png"&gt;&lt;img height="342" width="475" src="/shawnweisfeld/image_thumb_1F092597.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The first step is to add to our data context a method that maps to our stored procedure. You can see we start off with a Function attribute that tells LINQ to SQL what stored procedure to use. Additionally we decorate the parameters on our method with Parameter attributes that tell LINQ to SQL how to map the parameters. Then we just call our base classes ExecuteMethodCall passing along all the attributes (using the .NET reflection MethodInfo class), and our parameter. &lt;/p&gt;
&lt;p&gt;&lt;a href="/shawnweisfeld/image_5A2CDB95.png"&gt;&lt;img height="292" width="845" src="/shawnweisfeld/image_thumb_05053FA8.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now we just need to use our new method.&lt;/p&gt;
&lt;p&gt;&lt;a href="/shawnweisfeld/image_38610304.png"&gt;&lt;img height="165" width="811" src="/shawnweisfeld/image_thumb_1C504419.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Here we can see we get the same results as we did in my last post. &lt;/p&gt;
&lt;p&gt;&lt;a href="/shawnweisfeld/image_5BADF7A9.png"&gt;&lt;img height="381" width="608" src="/shawnweisfeld/image_thumb_222AE7B2.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;In my next post we will use Multiple-Rowset to return multiple result sets from my stored procedure. &lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/313.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>sweisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/11/call-a-stored-procedure-with-linq-to-sql-and-without.aspx</guid>
            <pubDate>Sun, 12 Jul 2009 03:15:00 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/313.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/11/call-a-stored-procedure-with-linq-to-sql-and-without.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/313.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/313.aspx</trackback:ping>
        </item>
        <item>
            <title>A simple select with LINQ to SQL and without the designer</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the.aspx</link>
            <description>&lt;p&gt;Many folks poo-poo LINQ to SQL because they don’t like designers. On the other hand some developers, myself included, like knowing how things work behind the scenes, for those edge case moments when the designer cannot do something. The most common business case for this is if you want to LINQ to SQL-afy an existing suite of objects. Well using the designers is NOT a requirement of LINQ to SQL.&lt;/p&gt;  &lt;p&gt;Lets say for example you had an existing customer table and customer business object:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_1A0E037E.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_4EAE5FB9.png" width="458" height="180" /&gt;&lt;/a&gt; &lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_0039CD4F.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_4003B3D4.png" width="432" height="193" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Lets see if we can get LINQ to SQL to populate a list of customers from the database.&lt;/p&gt;  &lt;p&gt;Ok first we need to make sure we have a valid connection string.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_45DE576D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_137A83EE.png" width="1135" height="166" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The next step is to create our DataContext. If you have used LINQ to SQL you will know that this guy does all the heavy lifting when it comes to getting data from and pushing data to the database.&lt;/p&gt;  &lt;p&gt;Creating the DataContext is simple. Just create a new class and set its parent class to DataContext. (You will probably need to add a reference to System.Data.Linq.)  Once you have the class created create a private static member called for the mapping source, and a constructor. The mapping source tells LINQ if it should look for attributes on the object, or in an xml configuration file for instructions on how to map the object model to the db model. This constructor will be chained to our base class passing up the mapping source and the connection string.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_79A64DBE.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_5CBD28E9.png" width="896" height="186" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p&gt;Since we selected an Attribute Mapping Source, lets go and decorate our customer class. using the attributes in the System.Data.Linq.Mapping namespace I tell LINQ to SQL what db table our object maps to and what columns each of the properties map to. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_77F581EA.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_3BC9B642.png" width="518" height="328" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The next step is to add a helper method to our Data Context exposing the data so we can easily query it.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_2FC7C60E.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_28A88996.png" width="425" height="167" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p /&gt;  &lt;p /&gt;  &lt;p&gt;Now we can just write our LINQ query, just like normal. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_7644B616.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_360E9C9C.png" width="601" height="231" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;That is it a simple LINQ to SQL query without the designer. Here are the results of the above query.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/image_1991AABC.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://drowningintechnicaldebt.com/shawnweisfeld/image_thumb_75001D37.png" width="557" height="347" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In my next post I will kick this up a notch by using a stored procedure to get these same results. &lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/312.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>sweisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the.aspx</guid>
            <pubDate>Sun, 12 Jul 2009 02:57:42 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/312.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/07/11/a-simple-select-with-linq-to-sql-and-without-the.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/312.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/312.aspx</trackback:ping>
        </item>
        <item>
            <title>Extension Method to Resize an Image</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/06/28/extension-method-to-resize-an-image.aspx</link>
            <description>&lt;p&gt;I wrote this for an INETA project that I have been working on, but thought it would be great to share with everyone. We had a need to take an image and change its size. Below is an implementation of a Resize Extension Method on the .NET Image object. &lt;/p&gt;
&lt;p&gt; I borrowed some ideas from this post by Mark McDonnell (&lt;a href="http://weblogs.asp.net/markmcdonnell/archive/2008/03/09/resize-image-before-uploading-to-server.aspx"&gt;http://weblogs.asp.net/markmcdonnell/archive/2008/03/09/resize-image-before-uploading-to-server.aspx&lt;/a&gt;)&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Drawing;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Drawing.Drawing2D;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Demo&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;{&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; ResizeMode&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    { &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        Width,&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        Height,&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        Bigger&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ImageHelper&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Image Resize(&lt;span class="kwrd"&gt;this&lt;/span&gt; Image source, &lt;span class="kwrd"&gt;int&lt;/span&gt; size, ResizeMode mode)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;            &lt;span class="rem"&gt;//Convert the source image into a bitmap so we can work with it&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;            Bitmap originalBMP = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bitmap(source);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;            Image result;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;            &lt;span class="rem"&gt;// Calculate the new image dimensions&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; origWidth = originalBMP.Width;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; origHeight = originalBMP.Height;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; newWidth = 0;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; newHeight = 0;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;            &lt;span class="rem"&gt;//If the size mode is set to bigger then find the widest side&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (mode == ResizeMode.Bigger)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;            {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (origHeight &amp;gt; origWidth)&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;                    mode = ResizeMode.Height;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;                &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;                    mode = ResizeMode.Width;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;            }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;            &lt;span class="rem"&gt;//keeping the aspect ratio constant, calculate the new size&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (mode == ResizeMode.Width)&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;            {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;                newWidth = size;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;                newHeight = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)(size / ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)origWidth / (&lt;span class="kwrd"&gt;double&lt;/span&gt;)origHeight));&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;            }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;            {&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;                newHeight = size;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;                newWidth = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)(size / ((&lt;span class="kwrd"&gt;double&lt;/span&gt;)origHeight / (&lt;span class="kwrd"&gt;double&lt;/span&gt;)origWidth));&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;            }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;            &lt;span class="rem"&gt;// Create a new bitmap which will hold the previous resized bitmap&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt;            Bitmap newBMP = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bitmap(originalBMP, newWidth, newHeight);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  56:  &lt;/span&gt;            &lt;span class="rem"&gt;// Create a graphic based on the new bitmap&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  57:  &lt;/span&gt;            &lt;span class="kwrd"&gt;using&lt;/span&gt; (Graphics oGraphics = Graphics.FromImage(newBMP))&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  58:  &lt;/span&gt;            {&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  59:  &lt;/span&gt;                &lt;span class="rem"&gt;// Set the properties for the new graphic file&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  60:  &lt;/span&gt;                oGraphics.SmoothingMode = SmoothingMode.AntiAlias;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  61:  &lt;/span&gt;                oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  62:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  63:  &lt;/span&gt;                &lt;span class="rem"&gt;// Draw the new graphic based on the resized bitmap&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  64:  &lt;/span&gt;                oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  65:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  66:  &lt;/span&gt;                &lt;span class="rem"&gt;// Save the new graphic file to the server&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  67:  &lt;/span&gt;                result = newBMP.Clone() &lt;span class="kwrd"&gt;as&lt;/span&gt; Image;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  68:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  69:  &lt;/span&gt;                &lt;span class="rem"&gt;// Once finished with the bitmap objects, we deallocate them.&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  70:  &lt;/span&gt;                originalBMP.Dispose();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  71:  &lt;/span&gt;                newBMP.Dispose();&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  72:  &lt;/span&gt;                oGraphics.Dispose();&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  73:  &lt;/span&gt;            }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  74:  &lt;/span&gt; &lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  75:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; result;&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  76:  &lt;/span&gt;        }&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  77:  &lt;/span&gt;    }&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;  78:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;&lt;style type="text/css"&gt;&lt;!--
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--&gt;&lt;/style&gt;

&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Using an extension method makes it really easy to use the new “resize” functionality:&lt;/p&gt;
&lt;div class="csharpcode"&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;            Image img = Image.FromFile(&lt;span class="str"&gt;"img.jpg"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            Image resized = img.Resize(100, ResizeMode.Bigger);&lt;/pre&gt;
&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            resized.Save(&lt;span class="str"&gt;"resized.jpg"&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;&lt;style type="text/css"&gt;&lt;!--
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
--&gt;&lt;/style&gt;

&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;So we went from a source size of 2304x1728 and 782 KB &lt;/p&gt;
&lt;p&gt;&lt;a href="/shawnweisfeld/image_0CCA186B.png"&gt;&lt;img border="0" width="712" src="/shawnweisfeld/image_thumb_57515645.png" alt="image" height="131" style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;to 100x75 and 23.3 KB&lt;/p&gt;
&lt;p&gt;&lt;a href="/shawnweisfeld/image_15D6A3EC.png"&gt;&lt;img border="0" width="709" src="/shawnweisfeld/image_thumb_4357C3AF.png" alt="image" height="137" style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now you to can shrink the size of your memories. :) &lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/308.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>sweisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/06/28/extension-method-to-resize-an-image.aspx</guid>
            <pubDate>Sun, 28 Jun 2009 23:52:00 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/308.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/06/28/extension-method-to-resize-an-image.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/308.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/308.aspx</trackback:ping>
        </item>
        <item>
            <title>Property Causing a Stack Dump</title>
            <link>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/06/16/property-causing-a-stack-dump.aspx</link>
            <description>&lt;p&gt;Got a call today, someone was getting a stack dump every time they tried to assign a value to a property. Here is a screen print of the problem they were having. can you spot the problem?&lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image001_74C9F7DB.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image001_thumb_33BB7877.jpg" width="488" height="822" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you said that the property is calling itself you get a gold star.  What was happening is that every time we tried to set the Name property, it calls the Name property to set it, and that called the Name property, and that called the Name property, over and over again, till .NET stack dumped. We are missing a backing variable. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image0017_586C8FEE.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001[7]" border="0" alt="clip_image001[7]" src="http://drowningintechnicaldebt.com/shawnweisfeld/clip_image0017_thumb_3E9859BF.jpg" width="444" height="643" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;By backing the property with a private variable, it removes the infinite recursion. Since the variable itself is private nobody can see it, or can use it outside the class, they are forced to use the property, and all is right with the world again!  &lt;/p&gt;&lt;img src="http://www.drowningintechnicaldebt.com/ShawnWeisfeld/aggbug/303.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>sweisfeld</dc:creator>
            <guid>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/06/16/property-causing-a-stack-dump.aspx</guid>
            <pubDate>Tue, 16 Jun 2009 05:26:50 GMT</pubDate>
            <wfw:comment>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/303.aspx</wfw:comment>
            <comments>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/06/16/property-causing-a-stack-dump.aspx#feedback</comments>
            <wfw:commentRss>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/comments/commentRss/303.aspx</wfw:commentRss>
            <trackback:ping>http://www.drowningintechnicaldebt.com/ShawnWeisfeld/services/trackbacks/303.aspx</trackback:ping>
        </item>
    </channel>
</rss>
