<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Andrew Hay - Visual Studio</title>
    <link>http://www.a7drew.com/blog/</link>
    <description>Thinking way too long about the subtitle</description>
    <language>en-us</language>
    <copyright>Andrew Hay</copyright>
    <lastBuildDate>Fri, 20 Aug 2010 23:02:26 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.12105.0</generator>
    <managingEditor>andrewcameronhay@hotmail.com</managingEditor>
    <webMaster>andrewcameronhay@hotmail.com</webMaster>
    <item>
      <trackback:ping>http://www.a7drew.com/blog/Trackback.aspx?guid=fdd5d3da-f623-4962-b321-fa18c0ab3871</trackback:ping>
      <pingback:server>http://www.a7drew.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.a7drew.com/blog/PermaLink,guid,fdd5d3da-f623-4962-b321-fa18c0ab3871.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.a7drew.com/blog/CommentView,guid,fdd5d3da-f623-4962-b321-fa18c0ab3871.aspx</wfw:comment>
      <wfw:commentRss>http://www.a7drew.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=fdd5d3da-f623-4962-b321-fa18c0ab3871</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was using a clean machine for some Azure development and it just happened to have
the developer edition of SQL Server, as the default instance, installed instead of
SQL Server Express Edition. When I pressed F5 to launch the local developer app fabric,
I received an error message about the local developer storage. By default, the local
developer storage is looking for .\SQLExpress on your machine.
</p>
        <p>
Here’s the error message that popped up in Visual Studio 2010:
</p>
        <p>
          <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Failed to initialize Development Storage service. See output window for more information." border="0" alt="Failed to initialize Development Storage service. See output window for more information." src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ConfiguringaSQLServerInstancewithAzureSD_DF84/azure01_1.png" width="499" height="208" />
        </p>
        <p>
I looked in the output window and found this message:
</p>
        <blockquote>
          <p>
Windows Azure Tools: Failed to initialize Development Storage service. Unable to start
Development Storage. Failed to start Development Storage: the SQL Server instance
‘.\SQLExpress’ could not be found.   Please configure the SQL Server instance
for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.
</p>
        </blockquote>
        <p>
I needed to configure the default instance of SQL Server for Azure local development.
So I searched online for “Azure DSInit” and the first hit shows how to invoke the
command.
</p>
        <p>
          <a title="http://msdn.microsoft.com/en-us/library/dd179457.aspx" href="http://msdn.microsoft.com/en-us/library/dd179457.aspx">http://msdn.microsoft.com/en-us/library/dd179457.aspx</a>
        </p>
        <p>
To configure development storage against the default SQL Server instance:
</p>
        <pre class="csharpcode">DSInit /sqlInstance:.</pre>
        <style type="text/css">.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; }
</style>
        <p>
The program DSInit.exe is found in the Azure SDK: 
</p>
        <p>
C:\Program Files\Windows Azure SDK\v1.0\bin\devstore\
</p>
        <p>
Once I ran that program to initialize the local development app storage, I was off
and running with my cloud development tasks.
</p>
        <img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=fdd5d3da-f623-4962-b321-fa18c0ab3871" />
      </body>
      <title>Configuring a local SQL Server Instance with Azure</title>
      <guid isPermaLink="false">http://www.a7drew.com/blog/PermaLink,guid,fdd5d3da-f623-4962-b321-fa18c0ab3871.aspx</guid>
      <link>http://www.a7drew.com/blog/2010/08/20/ConfiguringALocalSQLServerInstanceWithAzure.aspx</link>
      <pubDate>Fri, 20 Aug 2010 23:02:26 GMT</pubDate>
      <description>&lt;p&gt;
I was using a clean machine for some Azure development and it just happened to have
the developer edition of SQL Server, as the default instance, installed instead of
SQL Server Express Edition. When I pressed F5 to launch the local developer app fabric,
I received an error message about the local developer storage. By default, the local
developer storage is looking for .\SQLExpress on your machine.
&lt;/p&gt;
&lt;p&gt;
Here’s the error message that popped up in Visual Studio 2010:
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Failed to initialize Development Storage service. See output window for more information." border="0" alt="Failed to initialize Development Storage service. See output window for more information." src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ConfiguringaSQLServerInstancewithAzureSD_DF84/azure01_1.png" width="499" height="208"&gt; 
&lt;/p&gt;
&lt;p&gt;
I looked in the output window and found this message:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Windows Azure Tools: Failed to initialize Development Storage service. Unable to start
Development Storage. Failed to start Development Storage: the SQL Server instance
‘.\SQLExpress’ could not be found.&amp;nbsp;&amp;nbsp; Please configure the SQL Server instance
for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I needed to configure the default instance of SQL Server for Azure local development.
So I searched online for “Azure DSInit” and the first hit shows how to invoke the
command.
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://msdn.microsoft.com/en-us/library/dd179457.aspx" href="http://msdn.microsoft.com/en-us/library/dd179457.aspx"&gt;http://msdn.microsoft.com/en-us/library/dd179457.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
To configure development storage against the default SQL Server instance:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;DSInit /sqlInstance:.&lt;/pre&gt;
&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;p&gt;
The program DSInit.exe is found in the Azure SDK: 
&lt;/p&gt;
&lt;p&gt;
C:\Program Files\Windows Azure SDK\v1.0\bin\devstore\
&lt;/p&gt;
&lt;p&gt;
Once I ran that program to initialize the local development app storage, I was off
and running with my cloud development tasks.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=fdd5d3da-f623-4962-b321-fa18c0ab3871" /&gt;</description>
      <comments>http://www.a7drew.com/blog/CommentView,guid,fdd5d3da-f623-4962-b321-fa18c0ab3871.aspx</comments>
      <category>Azure</category>
      <category>SQL Server</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.a7drew.com/blog/Trackback.aspx?guid=0da8418b-fa06-4646-95e4-539ca754d570</trackback:ping>
      <pingback:server>http://www.a7drew.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.a7drew.com/blog/PermaLink,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.a7drew.com/blog/CommentView,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</wfw:comment>
      <wfw:commentRss>http://www.a7drew.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=0da8418b-fa06-4646-95e4-539ca754d570</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Behind the scenes, I see a lot of companies run on Excel and duct tape. So it's common
for clients to hand me a slab of data organized into neat little rows and columns.
Excel is just a handy way to throw some data over the wall and get things done. This
might be a list of dealers, a collection of user profiles, product information, or
anything that just needs to get somewhere else.
</p>
        <p>
Depending on the scenario, I'll might massage this data and slide it into a SQL Server
database or an XML file. I'm a web developer so I use the ADO.Net stack on a regular
basis. If I were a Windows client developer, I might prefer to solve this problem
with the Excel object model, but that really looks like more code to me, so here's
how I like to roll:
</p>
        <p>
The following code block accepts an Excel file path and returns an ordinary DataTable
object, which can be manipulated easily by the code that calls this method. The first
row of the Excel document becomes the columns in the DataTable object and each row
thereafter are DataRow objects.
</p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_2.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="148" alt="ImportDataFromExcel" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_thumb.png" width="244" border="0" />
          </a>
          <br />
(Click to enlarge)
</p>
        <p>
If you like, <a href="http://support.microsoft.com/kb/306023">take a look at both
techniques for working with Excel data</a> and see what one speaks to you. With this
block of code, I can happily accept large chunks of data from a client without spending
precious time fiddling with administrivia.
</p>
        <img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=0da8418b-fa06-4646-95e4-539ca754d570" />
      </body>
      <title>Importing Data From Excel In C#</title>
      <guid isPermaLink="false">http://www.a7drew.com/blog/PermaLink,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</guid>
      <link>http://www.a7drew.com/blog/2008/07/31/ImportingDataFromExcelInC.aspx</link>
      <pubDate>Thu, 31 Jul 2008 16:00:16 GMT</pubDate>
      <description>&lt;p&gt;
Behind the scenes, I see a lot of companies run on Excel and duct tape. So it's common
for clients to hand me a slab of data organized into neat little rows and columns.
Excel is just a handy way to throw some data over the wall and get things done. This
might be a list of dealers, a collection of user profiles, product information, or
anything that just needs to get somewhere else.
&lt;/p&gt;
&lt;p&gt;
Depending on the scenario, I'll might massage this data and slide it into a SQL Server
database or an XML file. I'm a web developer so I use the ADO.Net stack on a regular
basis. If I were a Windows client developer, I might prefer to solve this problem
with the Excel object model, but that really looks like more code to me, so here's
how I like to roll:
&lt;/p&gt;
&lt;p&gt;
The following code block accepts an Excel file path and returns an ordinary DataTable
object, which can be manipulated easily by the code that calls this method. The first
row of the Excel document becomes the columns in the DataTable object and each row
thereafter are DataRow objects.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="148" alt="ImportDataFromExcel" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_thumb.png" width="244" border="0" /&gt;&lt;/a&gt; 
&lt;br /&gt;
(Click to enlarge)
&lt;/p&gt;
&lt;p&gt;
If you like, &lt;a href="http://support.microsoft.com/kb/306023"&gt;take a look at both
techniques for working with Excel data&lt;/a&gt; and see what one speaks to you. With this
block of code, I can happily accept large chunks of data from a client without spending
precious time fiddling with administrivia.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=0da8418b-fa06-4646-95e4-539ca754d570" /&gt;</description>
      <comments>http://www.a7drew.com/blog/CommentView,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</comments>
      <category>asp.net</category>
      <category>software</category>
      <category>SQL Server</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.a7drew.com/blog/Trackback.aspx?guid=e56335bf-89d5-4cac-900c-73583fb5dba7</trackback:ping>
      <pingback:server>http://www.a7drew.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.a7drew.com/blog/PermaLink,guid,e56335bf-89d5-4cac-900c-73583fb5dba7.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.a7drew.com/blog/CommentView,guid,e56335bf-89d5-4cac-900c-73583fb5dba7.aspx</wfw:comment>
      <wfw:commentRss>http://www.a7drew.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e56335bf-89d5-4cac-900c-73583fb5dba7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
LINQ is an acronym for Language-Integrated Query and a new feature in v3.5 of the
.Net Framework from Microsoft. This new version of Microsoft .Net reached RTM status
a couple of weeks ago — this framework is chock full of brilliant things I can
use to improve my efficiency and effectiveness on daily tasks here at Pop Art.
</p>
        <p>
As one of my favorite features, LINQ helps me write data-driven application even faster
than what .Net 2.0 brought to the table. A common example starts with launching Visual
Studio 2008. After dragging a collection of tables from a SQL Server database onto
a surface in my solution, I can see a visualization of the columns in the tables as
well as the relationships between them. Click the following thumbnail to see a larger
image.
</p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-map_2.jpg" target="_blank">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="196" alt="database schema" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-map_thumb.jpg" width="244" border="0" />
          </a>
        </p>
        <p>
Next, I start writing data access code directly in my C# program as opposed to switching
languages and writing in the T-SQL language. Visual Studio gives me Intellisense here
too; as I type the name of a table and click the period key, all of the columns in
the table appear where the cursor is located. Big time saver. Huge! I'm certain that
I didn't misspell a column name and that my code will compile.
</p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-intellisense_2.jpg" target="_blank">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="192" alt="intellisense is beautiful" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-intellisense_thumb.jpg" width="244" border="0" />
          </a>
        </p>
        <p>
The syntax for LINQ in a C# program is very similar to the T-SQL language, which is
a "set based" language. LINQ statements are compiled, just like the rest
of my C# code. The first thing someone well versed in T-SQL will notice is that the
columns normally specified in a SELECT query are at the end of the LINQ statement
instead of the start as in T-SQL. The idea is that you're articulating your constraints
at the start of the LINQ statement and then pulling out the fields you need at the
very end.
</p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sample_2.jpg" target="_blank">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="169" alt="a LINQ sample" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sample_thumb.jpg" width="244" border="0" />
          </a>
        </p>
        <p>
Behind the scenes, LINQ is using the relationships expressed in the database to generate
T-SQL scripts on the fly. This is a clear line of demarcation for LINQ. If you're
using stored procedures exclusively for database access, then LINQ isn't going to
buy you much. You'll still get Intellisense inside Visual Studio and you can specify
an existing stored procedure instead of using the auto-generated SQL, but you're giving
up a lot of acceleration tools. Perhaps more than you're getting in return.
</p>
        <p>
LINQ really shines in multiple table joins and aggregation. The following two blocks
of code show a query is performed in LINQ and its equivalent T-SQL script. The query
retrieves product information from three tables where the list price is below a given
amount and a sub-category name exists. If you go the T-SQL route, you will still need
to write some C# code to call your database query.
</p>
        <p>
Which of the following versions would you rather author and support?
</p>
        <p>
          <strong>LINQ Version</strong>
        </p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-complex_2.jpg" target="_blank">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="201" alt="a more complex LINQ statement" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-complex_thumb.jpg" width="244" border="0" />
          </a>
        </p>
        <p>
          <strong>T-SQL Version</strong>
        </p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sql_4.jpg" target="_blank">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="154" alt="an equivalent T-SQL statement" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sql_thumb_1.jpg" width="244" border="0" />
          </a>
        </p>
        <p>
MSDN is a great online resource for developers and they really hit a home-run here.
They have a page with <a href="http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx" target="_blank">101
LINQ samples</a>. This is my preferred way to learn when I already know the surrounding
technologies and I want to fill in a specific gap. The page categorizes several ways
of retrieving and iterating over information. 
</p>
        <img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=e56335bf-89d5-4cac-900c-73583fb5dba7" />
      </body>
      <title>Understanding LINQ</title>
      <guid isPermaLink="false">http://www.a7drew.com/blog/PermaLink,guid,e56335bf-89d5-4cac-900c-73583fb5dba7.aspx</guid>
      <link>http://www.a7drew.com/blog/2007/12/19/UnderstandingLINQ.aspx</link>
      <pubDate>Wed, 19 Dec 2007 01:36:23 GMT</pubDate>
      <description>&lt;p&gt;
LINQ is an acronym for Language-Integrated Query and a new feature in v3.5 of the
.Net Framework from Microsoft. This new version of Microsoft .Net reached RTM status
a couple of weeks ago &amp;#8212; this framework is chock full of brilliant things I can
use to improve my efficiency and effectiveness on daily tasks here at Pop Art.
&lt;/p&gt;
&lt;p&gt;
As one of my favorite features, LINQ helps me write data-driven application even faster
than what .Net 2.0 brought to the table. A common example starts with launching Visual
Studio 2008. After dragging a collection of tables from a SQL Server database onto
a surface in my solution, I can see a visualization of the columns in the tables as
well as the relationships between them. Click the following thumbnail to see a larger
image.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-map_2.jpg" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="196" alt="database schema" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-map_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Next, I start writing data access code directly in my C# program as opposed to switching
languages and writing in the T-SQL language. Visual Studio gives me Intellisense here
too; as I type the name of a table and click the period key, all of the columns in
the table appear where the cursor is located. Big time saver. Huge! I'm certain that
I didn't misspell a column name and that my code will compile.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-intellisense_2.jpg" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="192" alt="intellisense is beautiful" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-intellisense_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The syntax for LINQ in a C# program is very similar to the T-SQL language, which is
a &amp;quot;set based&amp;quot; language. LINQ statements are compiled, just like the rest
of my C# code. The first thing someone well versed in T-SQL will notice is that the
columns normally specified in a SELECT query are at the end of the LINQ statement
instead of the start as in T-SQL. The idea is that you're articulating your constraints
at the start of the LINQ statement and then pulling out the fields you need at the
very end.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sample_2.jpg" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="169" alt="a LINQ sample" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sample_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Behind the scenes, LINQ is using the relationships expressed in the database to generate
T-SQL scripts on the fly. This is a clear line of demarcation for LINQ. If you're
using stored procedures exclusively for database access, then LINQ isn't going to
buy you much. You'll still get Intellisense inside Visual Studio and you can specify
an existing stored procedure instead of using the auto-generated SQL, but you're giving
up a lot of acceleration tools. Perhaps more than you're getting in return.
&lt;/p&gt;
&lt;p&gt;
LINQ really shines in multiple table joins and aggregation. The following two blocks
of code show a query is performed in LINQ and its equivalent T-SQL script. The query
retrieves product information from three tables where the list price is below a given
amount and a sub-category name exists. If you go the T-SQL route, you will still need
to write some C# code to call your database query.
&lt;/p&gt;
&lt;p&gt;
Which of the following versions would you rather author and support?
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;LINQ Version&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-complex_2.jpg" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="201" alt="a more complex LINQ statement" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-complex_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;T-SQL Version&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sql_4.jpg" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="154" alt="an equivalent T-SQL statement" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/UnderstandingLINQ_8EA2/linq-sql_thumb_1.jpg" width="244" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
MSDN is a great online resource for developers and they really hit a home-run here.
They have a page with &lt;a href="http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx" target="_blank"&gt;101
LINQ samples&lt;/a&gt;. This is my preferred way to learn when I already know the surrounding
technologies and I want to fill in a specific gap. The page categorizes several ways
of retrieving and iterating over information. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=e56335bf-89d5-4cac-900c-73583fb5dba7" /&gt;</description>
      <comments>http://www.a7drew.com/blog/CommentView,guid,e56335bf-89d5-4cac-900c-73583fb5dba7.aspx</comments>
      <category>LINQ</category>
      <category>SQL Server</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.a7drew.com/blog/Trackback.aspx?guid=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1</trackback:ping>
      <pingback:server>http://www.a7drew.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.a7drew.com/blog/PermaLink,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.a7drew.com/blog/CommentView,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</wfw:comment>
      <wfw:commentRss>http://www.a7drew.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <a style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" href="http://www.sliver.com/dotnet/SnippetCompiler/">
          <img style="float: right" alt="Snippet Compiler" hspace="6" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/MyFirstLegitUseofSnippetCompiler_134FE/snippetcompiler_7d4925aa-cbf5-4bea-a953-25e5c0d35e3e.png" vspace="6" border="0" />
        </a>
        <p>
Like many of the three of you who subscribe my blog, I download a bunch
of tools &amp; utilities that I read about online and seldom have an opportunity
to use on a real project. 
</p>
        <p>
Today was my first bona fide use of the <a href="http://www.sliver.com/dotnet/SnippetCompiler/" target="_blank">Snippet
Compiler</a> and it just plain rocked. Its a small client application that
can take the place of many throw-away command line programs written just
to test out a concept. The application launches fast and I can start <strong>writing and executing</strong> my
code immediately. I don't need to select a project template, name it, or any
other of the standard housekeeping items. It even has statement completion!
</p>
        <p>
I was working on an existing ASP.Net v1.1 code base for a quick maintenance project.
I gleaned a test order number from the system and quickly realized my
specific test required an <strong>obfuscated</strong> order number from
the following "simple" and "natural" function:
</p>
        <div style="clear: both; background: #000; font: 8pt lucida console, times new roman">
          <p style="color: #00ff00">
//=====================================================================<br />
/// &lt;summary&gt;<br />
///    This method performs exactly the opposite action as<br />
///    EncodeOrderId(), and is meant as the natual companion to that<br />
///    method.  Performs a very simple wrapping bit shift (4 bits
wide,<br />
///    towards the most significant bit) on the input value (unsigned<br />
///    32 bit integer) and returns it as a signed 32 bit integer.<br />
/// &lt;/summary&gt;<br />
/// &lt;param name="orderId"&gt;Value to decode.&lt;/param&gt;<br />
/// &lt;returns&gt;Decoded value.&lt;/returns&gt;<br />
//=====================================================================<br />
public static int DecodeOrderId( uint orderId )<br />
{<br />
   int newOrderId = (int) (( orderId &lt;&lt; 4 ) | ( orderId &gt;&gt; 28
));<br /><br />
   if ( newOrderId &lt; 1 )<br />
   {<br />
      throw( new ArgumentException( "Invalid orderId: '"
+<br />
         orderId.ToString() + "'.", "orderId"
));<br />
   } 
<br /><br />
   return( newOrderId );<br />
} 
</p>
        </div>
        <p>
I was doing integration testing and further more, I was nearly done. I didn't
feel like firing up VS.Net to figure out how to get my test order number obfuscated,
so I thought about it and decided to have a spontaneous moment. 
</p>
        <p>
I (1) fired up the Snippet Compiler, (2) added a reference to the assembly and (3)
wrote a single line of code that called the static method DecodeOrderId() which
wrote the result to the console output. Booya!
</p>
        <img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1" />
      </body>
      <title>My First Legit Use of Snippet Compiler</title>
      <guid isPermaLink="false">http://www.a7drew.com/blog/PermaLink,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</guid>
      <link>http://www.a7drew.com/blog/2007/07/06/MyFirstLegitUseOfSnippetCompiler.aspx</link>
      <pubDate>Fri, 06 Jul 2007 05:20:48 GMT</pubDate>
      <description>&lt;a style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" href="http://www.sliver.com/dotnet/SnippetCompiler/"&gt;&lt;img style="float: right" alt="Snippet Compiler" hspace="6" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/MyFirstLegitUseofSnippetCompiler_134FE/snippetcompiler_7d4925aa-cbf5-4bea-a953-25e5c0d35e3e.png" vspace="6" border="0"&gt;&lt;/a&gt; 
&lt;p&gt;
Like many of the three of you who&amp;nbsp;subscribe my blog, I download&amp;nbsp;a bunch
of tools &amp;amp; utilities&amp;nbsp;that I&amp;nbsp;read about online and seldom have an opportunity
to use on a real project. 
&lt;/p&gt;
&lt;p&gt;
Today was my first&amp;nbsp;bona fide use of the &lt;a href="http://www.sliver.com/dotnet/SnippetCompiler/" target="_blank"&gt;Snippet
Compiler&lt;/a&gt; and it just plain rocked. Its a&amp;nbsp;small client application&amp;nbsp;that
can take the place of&amp;nbsp;many&amp;nbsp;throw-away command line programs written just
to test out a concept. The application launches&amp;nbsp;fast and I can start &lt;strong&gt;writing&amp;nbsp;and&amp;nbsp;executing&lt;/strong&gt;&amp;nbsp;my
code immediately.&amp;nbsp;I don't need to select a project template, name it, or any
other of the standard housekeeping items. It even has statement completion!
&lt;/p&gt;
&lt;p&gt;
I was working on an existing ASP.Net v1.1 code base for a quick maintenance project.
I gleaned a test&amp;nbsp;order number&amp;nbsp;from the system and&amp;nbsp;quickly realized&amp;nbsp;my
specific test required&amp;nbsp;an &lt;strong&gt;obfuscated&lt;/strong&gt; order number&amp;nbsp;from
the following&amp;nbsp;"simple" and "natural" function:
&lt;/p&gt;
&lt;div style="clear: both; background: #000; font: 8pt lucida console, times new roman"&gt;
&lt;p style="color: #00ff00"&gt;
//=====================================================================&lt;br&gt;
/// &amp;lt;summary&amp;gt;&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; This method performs exactly the opposite action as&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; EncodeOrderId(), and is meant as the natual companion to that&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; method.&amp;nbsp; Performs a very simple wrapping bit shift (4 bits
wide,&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; towards the most significant bit) on the input value (unsigned&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; 32 bit integer) and returns it as a signed 32 bit integer.&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
/// &amp;lt;param name="orderId"&amp;gt;Value to decode.&amp;lt;/param&amp;gt;&lt;br&gt;
/// &amp;lt;returns&amp;gt;Decoded value.&amp;lt;/returns&amp;gt;&lt;br&gt;
//=====================================================================&lt;br&gt;
public static int DecodeOrderId( uint orderId )&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; int newOrderId = (int) (( orderId &amp;lt;&amp;lt; 4 ) | ( orderId &amp;gt;&amp;gt; 28
));&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; if ( newOrderId &amp;lt; 1 )&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw( new ArgumentException( "Invalid orderId: '"
+&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderId.ToString() + "'.", "orderId"
));&lt;br&gt;
&amp;nbsp;&amp;nbsp; } 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; return( newOrderId );&lt;br&gt;
} 
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
I was doing integration testing and further more, I was nearly done.&amp;nbsp;I didn't
feel like firing up VS.Net&amp;nbsp;to figure out how to get my test order number obfuscated,
so I&amp;nbsp;thought about it and decided to have a spontaneous&amp;nbsp;moment. 
&lt;/p&gt;
&lt;p&gt;
I (1) fired up the Snippet Compiler, (2) added a reference to the assembly and (3)
wrote a single line of code&amp;nbsp;that called the static method DecodeOrderId()&amp;nbsp;which
wrote&amp;nbsp;the result to the console output. Booya!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1" /&gt;</description>
      <comments>http://www.a7drew.com/blog/CommentView,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</comments>
      <category>asp.net</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.a7drew.com/blog/Trackback.aspx?guid=94d46088-9e58-4d36-9b7d-83ff299d6581</trackback:ping>
      <pingback:server>http://www.a7drew.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.a7drew.com/blog/PermaLink,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.a7drew.com/blog/CommentView,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</wfw:comment>
      <wfw:commentRss>http://www.a7drew.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=94d46088-9e58-4d36-9b7d-83ff299d6581</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://pdx.techevents.info/codecamp/3/default.aspx" target="_blank">PDX
Code Camp</a> is next weekend, May 19th and 20th. I've been preparing a talk on how
to <a href="http://pdx.techevents.info/codecamp/3/SessionInfo.aspx?ID=24d5eb46-755c-40ab-806e-93077470b959" target="_blank">create
and use X.509 certificates</a>. Developers need this technology for local testing
of plain old ASP.Net sites, Web Services Enhancements (WSE) or Windows Communication
Foundation (WCF) code. 
</p>
        <p>
The Windows SDK and Visual Studio.Net have some good tools for helping developers
use certificates. I'll show some certificate basics, common examples of certs
in action and tools that help us along the way. My goal is to get the session
attendees comfortable with creating &amp; installing certificates on
their local machine in a variety of code scenarios - that seems like a reasonable
task for a 60 minute presentation and 15 minutes of Q &amp; A.
</p>
        <p>
Just for fun, I worked on a local checkout of <a href="http://code.google.com/p/dotnetopenid/" target="_blank">DotNetOpenID</a> and
implemented SSL for the authentication steps. A lot of the other code in
the presentation is based on the excellent examples from <a href="http://www.dasblonde.net/" target="_blank">Michele
Leroux Bustamante</a>. She does a great job of providing info on these topics for
the developer community.
</p>
        <p>
I have to leave for New London, CT on Sunday so I can only attend one day of this
developer event. Normally, that would suck big time, but I'm also gearing up
for a week long <a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;tabid=20">IDesign
WCF Master Class</a> at <a href="http://training.franklins.net/" target="_blank">Carl
Franklins house</a>. When it rains, it pours!
</p>
        <img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=94d46088-9e58-4d36-9b7d-83ff299d6581" />
      </body>
      <title>Portland Code Camp</title>
      <guid isPermaLink="false">http://www.a7drew.com/blog/PermaLink,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</guid>
      <link>http://www.a7drew.com/blog/2007/05/14/PortlandCodeCamp.aspx</link>
      <pubDate>Mon, 14 May 2007 05:07:20 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://pdx.techevents.info/codecamp/3/default.aspx" target="_blank"&gt;PDX
Code Camp&lt;/a&gt; is next weekend, May 19th and 20th. I've been preparing a talk on how
to &lt;a href="http://pdx.techevents.info/codecamp/3/SessionInfo.aspx?ID=24d5eb46-755c-40ab-806e-93077470b959" target="_blank"&gt;create
and use X.509 certificates&lt;/a&gt;. Developers need this technology for local testing
of&amp;nbsp;plain old&amp;nbsp;ASP.Net sites, Web Services Enhancements (WSE) or Windows Communication
Foundation (WCF) code. 
&lt;/p&gt;
&lt;p&gt;
The Windows SDK and Visual Studio.Net have some good tools for helping developers
use certificates. I'll show some certificate basics,&amp;nbsp;common examples of certs
in&amp;nbsp;action and tools that help us along the way. My goal is to get&amp;nbsp;the session
attendees&amp;nbsp;comfortable with creating&amp;nbsp;&amp;amp; installing certificates&amp;nbsp;on
their local machine in a variety of code scenarios - that seems like a reasonable
task for a 60 minute presentation&amp;nbsp;and 15 minutes of Q &amp;amp; A.
&lt;/p&gt;
&lt;p&gt;
Just for fun, I worked on a local checkout of &lt;a href="http://code.google.com/p/dotnetopenid/" target="_blank"&gt;DotNetOpenID&lt;/a&gt; and
implemented SSL for the&amp;nbsp;authentication steps.&amp;nbsp;A lot of the other code in
the presentation is based on the excellent examples from&amp;nbsp;&lt;a href="http://www.dasblonde.net/" target="_blank"&gt;Michele
Leroux Bustamante&lt;/a&gt;. She does a great job of providing info on these topics for
the developer community.
&lt;/p&gt;
&lt;p&gt;
I have to leave for New London, CT on Sunday so I can only attend one day of this
developer&amp;nbsp;event. Normally, that would suck big time, but I'm also gearing up
for a week long&amp;nbsp;&lt;a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;amp;tabid=20"&gt;IDesign
WCF Master Class&lt;/a&gt; at &lt;a href="http://training.franklins.net/" target="_blank"&gt;Carl
Franklins house&lt;/a&gt;. When it rains, it pours!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=94d46088-9e58-4d36-9b7d-83ff299d6581" /&gt;</description>
      <comments>http://www.a7drew.com/blog/CommentView,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</comments>
      <category>asp.net</category>
      <category>CardSpace</category>
      <category>events</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.a7drew.com/blog/Trackback.aspx?guid=9e7c492f-945a-409a-b6f3-85364ad81149</trackback:ping>
      <pingback:server>http://www.a7drew.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.a7drew.com/blog/PermaLink,guid,9e7c492f-945a-409a-b6f3-85364ad81149.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.a7drew.com/blog/CommentView,guid,9e7c492f-945a-409a-b6f3-85364ad81149.aspx</wfw:comment>
      <wfw:commentRss>http://www.a7drew.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9e7c492f-945a-409a-b6f3-85364ad81149</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There are tons of blog entries <a href="http://wpfwonderland.wordpress.com/2007/01/21/wpfe-fix-missing-intellisense-in-visual-studio/" target="_blank">like
this one explaining how to get intellisense</a> for WPF/e using the February 2007
CTP. The SDK for that release has a file named wpfe.xsd and you drop it into your
VS.Net schema folder here:
</p>
        <p>
          <code>C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas</code>
        </p>
        <p>
I'm using the Silverlight 1.1 alpha bits, and the 1.1 SDK doesn't have a file named
wpfe.xsd, so I was baffled for a minute. The Silverlight 1.1 SDK is laid out quite
differently and comes in a handy zip file instead of a chunky MSI file like its predecessor.
</p>
        <p>
Perhaps its just too early on a Sunday morning, but it took me a few minutes to realize
that (A) the 1.1 SDK does have a file named Silverlight.xsd and (2) dropping
Silverlight.xsd into my VS.Net schema folder does the trick. I'm going back to bed.
</p>
        <img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=9e7c492f-945a-409a-b6f3-85364ad81149" />
      </body>
      <title>Intellisense for XAML using Silverlight in Visual Studio.Net</title>
      <guid isPermaLink="false">http://www.a7drew.com/blog/PermaLink,guid,9e7c492f-945a-409a-b6f3-85364ad81149.aspx</guid>
      <link>http://www.a7drew.com/blog/2007/05/06/IntellisenseForXAMLUsingSilverlightInVisualStudioNet.aspx</link>
      <pubDate>Sun, 06 May 2007 16:38:50 GMT</pubDate>
      <description>&lt;p&gt;
There are tons of blog entries &lt;a href="http://wpfwonderland.wordpress.com/2007/01/21/wpfe-fix-missing-intellisense-in-visual-studio/" target="_blank"&gt;like
this one explaining how to get intellisense&lt;/a&gt; for WPF/e using the February 2007
CTP. The SDK for that release has a file named wpfe.xsd and you drop it into your
VS.Net schema folder here:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
I'm using the Silverlight 1.1 alpha bits, and the 1.1 SDK doesn't have a file named
wpfe.xsd, so I was baffled for a minute. The Silverlight 1.1 SDK is laid out quite
differently and comes in a handy zip file instead of a chunky MSI file like its predecessor.
&lt;/p&gt;
&lt;p&gt;
Perhaps its just too early on a Sunday morning, but it took me a few minutes to realize
that (A) the 1.1 SDK&amp;nbsp;does have&amp;nbsp;a file named Silverlight.xsd and (2) dropping
Silverlight.xsd into my VS.Net schema folder does the trick. I'm going back to bed.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=9e7c492f-945a-409a-b6f3-85364ad81149" /&gt;</description>
      <comments>http://www.a7drew.com/blog/CommentView,guid,9e7c492f-945a-409a-b6f3-85364ad81149.aspx</comments>
      <category>Silverlight</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.a7drew.com/blog/Trackback.aspx?guid=63b89405-d50d-4ff6-b1af-351b5f1e55a6</trackback:ping>
      <pingback:server>http://www.a7drew.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.a7drew.com/blog/PermaLink,guid,63b89405-d50d-4ff6-b1af-351b5f1e55a6.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.a7drew.com/blog/CommentView,guid,63b89405-d50d-4ff6-b1af-351b5f1e55a6.aspx</wfw:comment>
      <wfw:commentRss>http://www.a7drew.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=63b89405-d50d-4ff6-b1af-351b5f1e55a6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was chatting with my pal <a href="http://whitepdx.com/blogs/kelly/default.aspx" target="_blank">Kelly</a> at
work last week about code snippets. This weekend, I had a pile of dirty dishes to
clean, so I fired up my laptop and downloaded the archived <a href="http://www.dotnetrocks.com/default.aspx?showNum=128" target="_blank">DotNetRocks
interview with Michael Palermo</a> on code snippets. Before I knew it, the dishes
were clean and I had refresher on code snippets! 
</p>
        <p>
I took a look at Palermo's site, <a title="http://www.gotcodesnippets.com/" href="http://www.gotcodesnippets.com">www.gotcodesnippets.com</a>.
I was looking for some snippets I'd could install. I downloaded one that
creates a property whose value is stored in the ASP.Net viewstate. I do that technique
quite a bit, so it'll be fun to hit ctrl+k+x to run that snippet.
</p>
        <p>
Next, I was interested in writing one by myself, just to see what it was like. I had
downloaded the <a href="http://www.gotcodesnippets.com/1109.snippet" target="_blank">ternary
code snippet</a>, but I wasn't to warm and fuzzy about it. The snippet ought to have
given me the opportunity to type in the variables using the special code snippet mode
before reverting back to standard mode in Visual Studio. So, I grabbed their code,
made a few changes and now creates a line of code with a ternary operator in it -
just how I like. Here' the snippet that I dropped into my snippet folder.
</p>
        <p>
          <strong>
            <em>Folder:</em>
          </strong> \My Documents\Visual Studio 2005\Code Snippets\Visual
C#\My Code Snippets
</p>
        <p>
          <strong>
            <em>ternary.snippet XML File:</em>
          </strong>
        </p>
        <p>
        </p>
        <pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
   &lt;CodeSnippet Format="1.0.0"&gt;
      &lt;Header&gt;
         &lt;Title&gt;Ternary&lt;/Title&gt;
         &lt;Shortcut&gt;ter&lt;/Shortcut&gt;
         &lt;Description&gt;Custom code snippet for ternary operator&lt;/Description&gt;
         &lt;Author&gt;andrewdothay&lt;/Author&gt;
         &lt;SnippetTypes&gt;
            &lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;
         &lt;/SnippetTypes&gt;
      &lt;/Header&gt;
      &lt;Snippet&gt;
         &lt;Declarations&gt;
             &lt;Literal&gt;
                 &lt;ID&gt;result&lt;/ID&gt;
                 &lt;ToolTip&gt;Replace with the field or property that will recieve the value&lt;/ToolTip&gt;
                 &lt;Default&gt;result&lt;/Default&gt;
             &lt;/Literal&gt;
             &lt;Literal&gt;
                 &lt;ID&gt;expression&lt;/ID&gt;
                 &lt;ToolTip&gt;Replace with the expression to compare&lt;/ToolTip&gt;
                 &lt;Default&gt;expression&lt;/Default&gt;
             &lt;/Literal&gt;
             &lt;Literal&gt;
                 &lt;ID&gt;trueValue&lt;/ID&gt;
                 &lt;ToolTip&gt;Replace with the value if the expression is true&lt;/ToolTip&gt;
                 &lt;Default&gt;trueValue&lt;/Default&gt;
             &lt;/Literal&gt;
             &lt;Literal&gt;
                 &lt;ID&gt;falseValue&lt;/ID&gt;
                 &lt;ToolTip&gt;Replace with the value if the expression is false&lt;/ToolTip&gt;
                 &lt;Default&gt;falseValue&lt;/Default&gt;
             &lt;/Literal&gt;
         &lt;/Declarations&gt;
         &lt;Code Language="csharp"&gt;
            &lt;![CDATA[ $result$ = ( $expression$ ) ? $trueValue$ : $falseValue$;$end$]]&gt;
         &lt;/Code&gt;
      &lt;/Snippet&gt;
   &lt;/CodeSnippet&gt;
&lt;/CodeSnippets&gt;
</pre>
        <p>
This snippet uses four variables. The &lt;Code&gt; element contains placeholders for
the line that will be emitted by the code snippet. The "$" symbol surrounds the variable
so its easily identifiable by the snippet engine. When Visual Studio is in the special
mode, I can tab between the variable fields to enter the value, then hit tab+tab to
switch back to normal view after I've entered in the customizations. Sweet!
</p>
        <p>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
</p>
        <p>
I just found this <a href="http://channel9.msdn.com/Showpost.aspx?postid=295242" target="_blank">four
minute screencast</a> on Channel 9 too! She does an excellent job of showing one up
close.
</p>
        <img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=63b89405-d50d-4ff6-b1af-351b5f1e55a6" />
      </body>
      <title>Writing Custom Code Snippets</title>
      <guid isPermaLink="false">http://www.a7drew.com/blog/PermaLink,guid,63b89405-d50d-4ff6-b1af-351b5f1e55a6.aspx</guid>
      <link>http://www.a7drew.com/blog/2007/04/01/WritingCustomCodeSnippets.aspx</link>
      <pubDate>Sun, 01 Apr 2007 23:51:09 GMT</pubDate>
      <description>&lt;p&gt;
I was chatting with my pal &lt;a href="http://whitepdx.com/blogs/kelly/default.aspx" target="_blank"&gt;Kelly&lt;/a&gt; at
work last week about code snippets. This weekend, I had a pile of dirty dishes to
clean, so I fired up my laptop and downloaded the archived &lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=128" target="_blank"&gt;DotNetRocks
interview with Michael Palermo&lt;/a&gt; on code snippets. Before I knew it, the dishes
were clean and I had refresher on code snippets! 
&lt;/p&gt;
&lt;p&gt;
I took a look at Palermo's site, &lt;a title="http://www.gotcodesnippets.com/" href="http://www.gotcodesnippets.com"&gt;www.gotcodesnippets.com&lt;/a&gt;.
I was looking for some&amp;nbsp;snippets I'd&amp;nbsp;could install. I downloaded one that
creates a property whose value is stored in the ASP.Net viewstate. I do that technique
quite a bit, so it'll be fun to hit ctrl+k+x to run that snippet.
&lt;/p&gt;
&lt;p&gt;
Next, I was interested in writing one by myself, just to see what it was like. I had
downloaded the &lt;a href="http://www.gotcodesnippets.com/1109.snippet" target="_blank"&gt;ternary
code snippet&lt;/a&gt;, but I wasn't to warm and fuzzy about it. The snippet ought to have
given me the opportunity to type in the variables using the special code snippet mode
before reverting back to standard mode in Visual Studio. So, I grabbed their code,
made a few changes and now creates a line of code with a ternary operator in it -
just how I like. Here' the snippet that I dropped into my snippet folder.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;em&gt;Folder:&lt;/em&gt;&lt;/strong&gt; \My Documents\Visual Studio 2005\Code Snippets\Visual
C#\My Code Snippets
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;em&gt;ternary.snippet XML File:&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&amp;gt;
   &amp;lt;CodeSnippet Format="1.0.0"&amp;gt;
      &amp;lt;Header&amp;gt;
         &amp;lt;Title&amp;gt;Ternary&amp;lt;/Title&amp;gt;
         &amp;lt;Shortcut&amp;gt;ter&amp;lt;/Shortcut&amp;gt;
         &amp;lt;Description&amp;gt;Custom code snippet for ternary operator&amp;lt;/Description&amp;gt;
         &amp;lt;Author&amp;gt;andrewdothay&amp;lt;/Author&amp;gt;
         &amp;lt;SnippetTypes&amp;gt;
            &amp;lt;SnippetType&amp;gt;Expansion&amp;lt;/SnippetType&amp;gt;
         &amp;lt;/SnippetTypes&amp;gt;
      &amp;lt;/Header&amp;gt;
      &amp;lt;Snippet&amp;gt;
         &amp;lt;Declarations&amp;gt;
             &amp;lt;Literal&amp;gt;
                 &amp;lt;ID&amp;gt;result&amp;lt;/ID&amp;gt;
                 &amp;lt;ToolTip&amp;gt;Replace with the field or property that will recieve the value&amp;lt;/ToolTip&amp;gt;
                 &amp;lt;Default&amp;gt;result&amp;lt;/Default&amp;gt;
             &amp;lt;/Literal&amp;gt;
             &amp;lt;Literal&amp;gt;
                 &amp;lt;ID&amp;gt;expression&amp;lt;/ID&amp;gt;
                 &amp;lt;ToolTip&amp;gt;Replace with the expression to compare&amp;lt;/ToolTip&amp;gt;
                 &amp;lt;Default&amp;gt;expression&amp;lt;/Default&amp;gt;
             &amp;lt;/Literal&amp;gt;
             &amp;lt;Literal&amp;gt;
                 &amp;lt;ID&amp;gt;trueValue&amp;lt;/ID&amp;gt;
                 &amp;lt;ToolTip&amp;gt;Replace with the value if the expression is true&amp;lt;/ToolTip&amp;gt;
                 &amp;lt;Default&amp;gt;trueValue&amp;lt;/Default&amp;gt;
             &amp;lt;/Literal&amp;gt;
             &amp;lt;Literal&amp;gt;
                 &amp;lt;ID&amp;gt;falseValue&amp;lt;/ID&amp;gt;
                 &amp;lt;ToolTip&amp;gt;Replace with the value if the expression is false&amp;lt;/ToolTip&amp;gt;
                 &amp;lt;Default&amp;gt;falseValue&amp;lt;/Default&amp;gt;
             &amp;lt;/Literal&amp;gt;
         &amp;lt;/Declarations&amp;gt;
         &amp;lt;Code Language="csharp"&amp;gt;
            &amp;lt;![CDATA[ $result$ = ( $expression$ ) ? $trueValue$ : $falseValue$;$end$]]&amp;gt;
         &amp;lt;/Code&amp;gt;
      &amp;lt;/Snippet&amp;gt;
   &amp;lt;/CodeSnippet&amp;gt;
&amp;lt;/CodeSnippets&amp;gt;
&lt;/pre&gt;
&lt;p&gt;
This snippet uses four variables. The &amp;lt;Code&amp;gt; element contains placeholders for
the line that will be emitted by the code snippet. The "$" symbol surrounds the variable
so its easily identifiable by the snippet engine. When Visual Studio is in the special
mode, I can tab between the variable fields to enter the value, then hit tab+tab to
switch back to normal view after I've entered in the customizations. Sweet!
&lt;/p&gt;
&lt;p&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;/p&gt;
&lt;p&gt;
I just found this &lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=295242" target="_blank"&gt;four
minute screencast&lt;/a&gt; on Channel 9 too! She does an excellent job of showing one up
close.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.a7drew.com/blog/aggbug.ashx?id=63b89405-d50d-4ff6-b1af-351b5f1e55a6" /&gt;</description>
      <comments>http://www.a7drew.com/blog/CommentView,guid,63b89405-d50d-4ff6-b1af-351b5f1e55a6.aspx</comments>
      <category>learning</category>
      <category>Visual Studio</category>
    </item>
  </channel>
</rss>