<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DDITDev : C#</title><link>http://blogs.msdn.com/dditweb/archive/tags/C_2300_/default.aspx</link><description>Tags: C#</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>LINQ to SQL and multiple result sets in Stored Procedures</title><link>http://blogs.msdn.com/dditweb/archive/2008/05/06/linq-to-sql-and-multiple-result-sets-in-stored-procedures.aspx</link><pubDate>Wed, 07 May 2008 00:34:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8463979</guid><dc:creator>dditweb</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/dditweb/comments/8463979.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dditweb/commentrss.aspx?PostID=8463979</wfw:commentRss><wfw:comment>http://blogs.msdn.com/dditweb/rsscomments.aspx?PostID=8463979</wfw:comment><description>&lt;p&gt;In this post I'm going to demonstrate how you would return and consume multiple result sets from a stored procedure in LINQ to SQL.&lt;/p&gt;  &lt;p&gt;Imagine you have a stored procedure like this one below. Very simple &amp;#8211; it&amp;#8217;s just returns all customers and all orders.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image001_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="231" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image001_thumb.jpg" width="320" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In my LINQ to SQL Data Context, I have the following tables.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image002_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="159" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image002_thumb.jpg" width="480" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As well as the stored procedure definition.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image003_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="66" alt="clip_image003" src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image003_thumb.jpg" width="240" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Simple enough so far!&lt;/p&gt;  &lt;p&gt;The first thing we need to do is create a partial class and define a new method returning type &amp;#8216;IMultipleResults&amp;#8217;. I&amp;#8217;ve defined the one below to accept one parameter, which is a customerId.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image004_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="154" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image004_thumb.jpg" width="640" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You&amp;#8217;ll notice that there&amp;#8217;s a few attributes you need to add.&lt;/p&gt;  &lt;p&gt;1. Function &amp;#8211; this is the name of the stored procedure that will be called. It&amp;#8217;s the same one we defined in our data context above. Note: the &lt;i&gt;actual&lt;/i&gt; stored procedure name is irrelevant - it must be the name you have given the stored&amp;#160; procedure on the data context (which will be the same 99% of the time I&amp;#8217;d imagine.)&lt;/p&gt;  &lt;p&gt;2. ResultType &amp;#8211; This is the mapping that basically says &amp;#8220;Make the first result type of &amp;#8216;Customer&amp;#8217; and the second result type of &amp;#8216;Order&amp;#8217;&amp;#8221;.&lt;/p&gt;  &lt;p&gt;Once we&amp;#8217;ve defined this method, we can go ahead and consume it from our UI and/or OM as shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image005_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="202" alt="clip_image005" src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/clip_image005_thumb.jpg" width="480" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As shown above, you call the method you defined, passing in a customer id in this case, which returns you a type of IMultipleResults. From there it&amp;#8217;s just a case of calling the &amp;#8216;GetResult&amp;#8217; method making sure to pass in the type of the object you want.&lt;/p&gt;  &lt;p&gt;The results are shown below!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="259" alt="image" src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/LINQtoSQLandmultipleresultsetsinStoredPr_CCC1/image_thumb_1.png" width="320" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I hope this helps!&lt;/p&gt;  &lt;p&gt;Jason&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8463979" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dditweb/archive/tags/Jason/default.aspx">Jason</category><category domain="http://blogs.msdn.com/dditweb/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.msdn.com/dditweb/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/dditweb/archive/tags/LINQ/default.aspx">LINQ</category></item><item><title>VS2008 Tip - Remove unused 'using' statements</title><link>http://blogs.msdn.com/dditweb/archive/2008/03/19/vs2008-tip-remove-unused-using-statements.aspx</link><pubDate>Wed, 19 Mar 2008 19:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8325907</guid><dc:creator>dditweb</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dditweb/comments/8325907.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dditweb/commentrss.aspx?PostID=8325907</wfw:commentRss><wfw:comment>http://blogs.msdn.com/dditweb/rsscomments.aspx?PostID=8325907</wfw:comment><description>&lt;P&gt;Did you know that VS2008 has a great feature to remove any unused 'using' statements in your code?&lt;/P&gt;
&lt;P&gt;Simply right click anywhere in your code file, select '&lt;STRONG&gt;Organize Usings&lt;/STRONG&gt;' and select '&lt;STRONG&gt;Remove Unused Usings&lt;/STRONG&gt;'.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=183 src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/VS2008TipRemoveunusedusingstatements_8A97/image11.png" width=350 mce_src="http://blogs.msdn.com/blogfiles/dditweb/WindowsLiveWriter/VS2008TipRemoveunusedusingstatements_8A97/image11.png"&gt; &lt;/P&gt;
&lt;P&gt;You then end up with only the using statements you are actually using! (no pun intended ;))&lt;/P&gt;
&lt;P&gt;Other options include sorting your current using statements, or removing and sorting at the same time..&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Jason&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt; - One of my colleagues just pointed out that you can also do this (as well as some other great stuff) for all files in your project(s) using the &lt;A title="PowerCommands for VS2008" href="http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionId=df3f0c30-3d37-4e06-9ef8-3bff3508be31" target=_blank mce_href="http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionId=df3f0c30-3d37-4e06-9ef8-3bff3508be31"&gt;PowerCommands for VS2008&lt;/A&gt;&amp;nbsp;add-in. Thanks Rick!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8325907" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dditweb/archive/tags/Jason/default.aspx">Jason</category><category domain="http://blogs.msdn.com/dditweb/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/dditweb/archive/tags/C_2300_/default.aspx">C#</category></item></channel></rss>