<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>Brownie's Bikes</title>
        <link>http://blog.brownie.com.au/category/1.aspx</link>
        <description>Brownie's Bikes</description>
        <language>en-AU</language>
        <copyright>Andrew Browne</copyright>
        <managingEditor>brownie@brownie.com.au</managingEditor>
        <generator>Subtext Version 1.9.5.177</generator>
        <item>
            <title>In Search of the Ultimate Data Access Layer - Summary</title>
            <link>http://blog.brownie.com.au/archive/2008/01/05/in-search-of-the-ultimate-data-access-layer---summary.aspx</link>
            <description>&lt;p&gt;This post will serve as a summary of my posts related to my not very scientific analysis of data access layers.  These posts won't be tutorials but more pointers to things I liked/didn't like about each method as well as the main bits of interesting code.  &lt;/p&gt;
&lt;p&gt;For more detail grab the code from: &lt;a href="http://code.google.com/p/browniesbikes/"&gt;http://code.google.com/p/browniesbikes/&lt;/a&gt;.  Along with the code is also my NUnit tests.&lt;/p&gt;
&lt;h3&gt;DataReaders and Stored Procs:&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://blog.brownie.com.au/archive/2007/11/26/data-readers-and-stored-procs.aspx"&gt;Listing Data&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;Retrieving a single item - implemented post coming soon&lt;/li&gt;
    &lt;li&gt;Inserting Data - implemented post coming soon&lt;/li&gt;
    &lt;li&gt;Updating Data - implemented post coming soon&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;TableAdapters:&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://blog.brownie.com.au/archive/2008/01/05/tableadapters---the-list.aspx"&gt;Listing Data&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;Retrieving a single item - implemented post coming soon&lt;/li&gt;
    &lt;li&gt;Inserting Data - implemented post coming soon&lt;/li&gt;
    &lt;li&gt;Updating Data - implemented post coming soon&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;NHibernate:&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;Implemented - posts coming soon&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;LinqToSQL&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;Implemented - posts coming soon&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;SubSonic&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;partially implemented&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Data Access Application Block (Enterprise Library)&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;meaning to implement it someday.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blog.brownie.com.au/aggbug/11.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Andrew Browne</dc:creator>
            <guid>http://blog.brownie.com.au/archive/2008/01/05/in-search-of-the-ultimate-data-access-layer---summary.aspx</guid>
            <pubDate>Sat, 05 Jan 2008 09:43:54 GMT</pubDate>
            <comments>http://blog.brownie.com.au/archive/2008/01/05/in-search-of-the-ultimate-data-access-layer---summary.aspx#feedback</comments>
            <wfw:commentRss>http://blog.brownie.com.au/comments/commentRss/11.aspx</wfw:commentRss>
        </item>
        <item>
            <title>TableAdapters - The List</title>
            <link>http://blog.brownie.com.au/archive/2008/01/05/tableadapters---the-list.aspx</link>
            <description>&lt;p&gt;Most of my post on retrieving my Product list focused on the Stored Procedure.  When it came time to implement the same list with a TableAdapter all that work was already done for me.  My steps became:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;New dataset. &lt;/li&gt;
    &lt;li&gt;Drag my stored procedure from server explorer. &lt;/li&gt;
    &lt;li&gt;Rename the table and tableadapter &lt;/li&gt;
    &lt;li&gt;And there we have it: &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="http://blog.brownie.com.au/images/blog_brownie_com_au/WindowsLiveWriter/TableAdaptersTheList_11DCB/image_2.png"&gt;&lt;img width="244" height="122" border="0" src="http://blog.brownie.com.au/images/blog_brownie_com_au/WindowsLiveWriter/TableAdaptersTheList_11DCB/image_thumb.png" alt="image" style="border-width: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I then double clicked on the designer and edited the codebehind file to allow my DataRows to implement my IProduct interface:&lt;/p&gt;
&lt;div style="background: white none repeat scroll 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    1&lt;/span&gt; &lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    2&lt;/span&gt; &lt;span style="color: blue;"&gt;using&lt;/span&gt; BrowniesBikes.DTO;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    3&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    4&lt;/span&gt; &lt;span style="color: blue;"&gt;namespace&lt;/span&gt; BrowniesBikes.Data.TableAdapter {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    5&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    6&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    7&lt;/span&gt;     &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ProductDS&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    8&lt;/span&gt;     {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;    9&lt;/span&gt;         &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ProductListRow&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IProduct&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   10&lt;/span&gt;         {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   11&lt;/span&gt; &lt;span style="color: blue;"&gt;            #region&lt;/span&gt; IProduct Members&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   12&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   13&lt;/span&gt;             &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;? PhotoID&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   14&lt;/span&gt;             {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   15&lt;/span&gt;                 &lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;throw&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.&lt;span style="color: rgb(43, 145, 175);"&gt;NotImplementedException&lt;/span&gt;(); }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   16&lt;/span&gt;                 &lt;span style="color: blue;"&gt;set&lt;/span&gt; { &lt;span style="color: blue;"&gt;throw&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.&lt;span style="color: rgb(43, 145, 175);"&gt;NotImplementedException&lt;/span&gt;(); }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   17&lt;/span&gt;             }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt;             ...etc...&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt; &lt;span style="color: blue;"&gt;            #endregion&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;         }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;     }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt; }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;My DAL class ended up with very little code:&lt;/p&gt;
&lt;div style="background: white none repeat scroll 0%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   18&lt;/span&gt;         &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;IProduct&lt;/span&gt;&amp;gt; GetProductList(&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   19&lt;/span&gt;             &lt;span style="color: blue;"&gt;string&lt;/span&gt; searchString, &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;             &lt;span style="color: blue;"&gt;string&lt;/span&gt; sortExpression, &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;             &lt;span style="color: blue;"&gt;int&lt;/span&gt; startRow, &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;             &lt;span style="color: blue;"&gt;int&lt;/span&gt; maxRows)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;         {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;             &lt;span style="color: blue;"&gt;int&lt;/span&gt; endRow = startRow + maxRows;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;             &lt;span style="color: rgb(43, 145, 175);"&gt;ProductListTableAdapter&lt;/span&gt; productListTableAdapter = &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   26&lt;/span&gt;                 &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ProductListTableAdapter&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   27&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   28&lt;/span&gt;             &lt;span style="color: blue;"&gt;int&lt;/span&gt;? totalProducts = 0;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt;             &lt;span style="color: rgb(43, 145, 175);"&gt;ProductDS&lt;/span&gt;.&lt;span style="color: rgb(43, 145, 175);"&gt;ProductListDataTable&lt;/span&gt; listDataTable = &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&gt;                 productListTableAdapter.GetData(&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&gt;                 searchString, &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&gt;                 startRow, &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;                 endRow, &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt;                 sortExpression, &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;                 &lt;span style="color: blue;"&gt;ref&lt;/span&gt; totalProducts); &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;             &lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;ProductDS&lt;/span&gt;.&lt;span style="color: rgb(43, 145, 175);"&gt;ProductListRow&lt;/span&gt; row &lt;span style="color: blue;"&gt;in&lt;/span&gt; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;                 listDataTable.Rows)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;             {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt;                 &lt;span style="color: blue;"&gt;yield&lt;/span&gt; &lt;span style="color: blue;"&gt;return&lt;/span&gt; row;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;             }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;         }&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Deceptively easy. Keep an eye out for my post on inserting and updating as well as TableAdapter maintenance. There are some major pain points coming your way.&lt;/p&gt;&lt;img src="http://blog.brownie.com.au/aggbug/10.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Andrew Browne</dc:creator>
            <guid>http://blog.brownie.com.au/archive/2008/01/05/tableadapters---the-list.aspx</guid>
            <pubDate>Sat, 05 Jan 2008 09:19:25 GMT</pubDate>
            <comments>http://blog.brownie.com.au/archive/2008/01/05/tableadapters---the-list.aspx#feedback</comments>
            <wfw:commentRss>http://blog.brownie.com.au/comments/commentRss/10.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DataReaders and Stored Procs - The List</title>
            <link>http://blog.brownie.com.au/archive/2007/11/26/datareaders-and-stored-procs---the-list.aspx</link>
            <description>&lt;div class="blogStory"&gt;   &lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; I'm going to write some example code to properly compare table adapters with my other options.&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Marc:&lt;/strong&gt; But you already hate table adapters how are you going to be objective?&lt;/p&gt;    &lt;p&gt;&lt;em&gt;...a day later...&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Me: &lt;/strong&gt;Okay I'll start with stored procedures and data readers, nothing can be less fun than that.&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;So I proceeded to have lots of fun implementing my web site data layer using data readers and stored procedures. &lt;/p&gt;  &lt;p&gt;To begin with I wanted to fill my GridView with some data. This is something I'm sure we've all done so many times. When I was first working with ASP.NET I begin with Scott Mitchell's &lt;a href="http://www.asp.net/learn/data-access/"&gt;data tutorials&lt;/a&gt;. These tutorial use dynamic SQL.  After lots of advice and help from the guys on the SQLDownUnder list I have eliminated any dynamic SQL from my stored procedure.  I think the result is nice and reasonably maintainable. This stored procedure has the following features that I find are usually requested in the systems I build:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Paging &lt;/li&gt;    &lt;li&gt;Sorting &lt;/li&gt;    &lt;li&gt;Searching &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;To do paging two queries are required one that returns the page of results and one that gets the total number of results.  I have chosen to make the total rows an output parameter for my stored procedure.  This has two advantages I can see.  The first advantage is that the where clause is repeated across both queries and this way they are in the same place for maintenance.  The second plus is that it allows a single database round trip to get the list.&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    1&lt;/span&gt; &lt;span style="color: green"&gt;-- Author:    &lt;/span&gt;    &lt;span style="color: green"&gt;Andrew Browne&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    2&lt;/span&gt; &lt;span style="color: green"&gt;-- Create date: 12 November 2007&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    3&lt;/span&gt; &lt;span style="color: green"&gt;-- Description:    Retrieves a product list one &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    4&lt;/span&gt; &lt;span style="color: green"&gt;-- &lt;/span&gt;            &lt;span style="color: green"&gt;page at a time&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    5&lt;/span&gt; &lt;span style="color: green"&gt;-- =============================================&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    6&lt;/span&gt; &lt;span style="color: blue"&gt;CREATE PROCEDURE &lt;/span&gt;[BrowniesBikes].[GetProductList]&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    7&lt;/span&gt;     @SearchString &lt;span style="color: blue"&gt;NVARCHAR&lt;/span&gt;(50) = &lt;span style="color: rgb(163,21,21)"&gt;''&lt;/span&gt;,&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    8&lt;/span&gt;     @StartRow &lt;span style="color: blue"&gt;INT &lt;/span&gt;= 1,&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;    9&lt;/span&gt;     @EndRow &lt;span style="color: blue"&gt;INT &lt;/span&gt;= 10,&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   10&lt;/span&gt;     @SortColumn &lt;span style="color: blue"&gt;NVARCHAR&lt;/span&gt;(50) = &lt;span style="color: rgb(163,21,21)"&gt;''&lt;/span&gt;,&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   11&lt;/span&gt;     @TotalProducts &lt;span style="color: blue"&gt;INT OUTPUT&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   12&lt;/span&gt; &lt;span style="color: blue"&gt;AS&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   13&lt;/span&gt; &lt;span style="color: blue"&gt;BEGIN&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   14&lt;/span&gt;     &lt;span style="color: blue"&gt;SET NOCOUNT ON&lt;/span&gt;;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   15&lt;/span&gt; &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   16&lt;/span&gt;     &lt;span style="color: blue"&gt;DECLARE &lt;/span&gt;@LIKE_SEARCH &lt;span style="color: blue"&gt;as nvarchar&lt;/span&gt;(50) &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   17&lt;/span&gt;     &lt;span style="color: blue"&gt;SET &lt;/span&gt;@LIKE_SEARCH = &lt;span style="color: rgb(163,21,21)"&gt;'%' &lt;/span&gt;+ &lt;span style="color: blue"&gt;lower&lt;/span&gt;(@SearchString) + &lt;span style="color: rgb(163,21,21)"&gt;'%'&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   18&lt;/span&gt; &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   19&lt;/span&gt;     &lt;span style="color: blue"&gt;SELECT &lt;/span&gt;@TotalProducts = &lt;span style="color: blue"&gt;COUNT&lt;/span&gt;(*) &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   20&lt;/span&gt;         &lt;span style="color: blue"&gt;FROM &lt;/span&gt;Production.Product &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   21&lt;/span&gt;         &lt;span style="color: blue"&gt;WHERE&lt;/span&gt;(&lt;span style="color: blue"&gt;lower&lt;/span&gt;(&lt;span style="color: blue"&gt;Name&lt;/span&gt;) &lt;span style="color: blue"&gt;LIKE &lt;/span&gt;@LIKE_SEARCH &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   22&lt;/span&gt;             &lt;span style="color: blue"&gt;OR lower&lt;/span&gt;(ProductNumber) &lt;span style="color: blue"&gt;LIKE &lt;/span&gt;@LIKE_SEARCH)&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   23&lt;/span&gt; &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   24&lt;/span&gt;     &lt;span style="color: blue"&gt;SELECT &lt;/span&gt;RowRank, ProductID, &lt;span style="color: blue"&gt;Name&lt;/span&gt;, ProductNumber &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   25&lt;/span&gt;         &lt;span style="color: blue"&gt;FROM &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   26&lt;/span&gt;         (&lt;span style="color: blue"&gt;SELECT &lt;/span&gt;ProductID, &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   27&lt;/span&gt;             &lt;span style="color: blue"&gt;Name&lt;/span&gt;, &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   28&lt;/span&gt;             ProductNumber, &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   29&lt;/span&gt;             ROW_NUMBER() &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   30&lt;/span&gt;             &lt;span style="color: blue"&gt;OVER&lt;/span&gt;(&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   31&lt;/span&gt;                 &lt;span style="color: blue"&gt;ORDER BY &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   32&lt;/span&gt;                     &lt;span style="color: blue"&gt;CASE WHEN &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   33&lt;/span&gt;                         @SortColumn = &lt;span style="color: rgb(163,21,21)"&gt;'ProductNumber' &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   34&lt;/span&gt;                     &lt;span style="color: blue"&gt;THEN &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   35&lt;/span&gt;                         ProductNumber&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   36&lt;/span&gt;                     &lt;span style="color: blue"&gt;ELSE &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   37&lt;/span&gt;                         &lt;span style="color: blue"&gt;Name&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   38&lt;/span&gt;                     &lt;span style="color: blue"&gt;END&lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   39&lt;/span&gt;                 ) &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   40&lt;/span&gt;         &lt;span style="color: blue"&gt;AS &lt;/span&gt;RowRank &lt;span style="color: blue"&gt;FROM &lt;/span&gt;Production.Product &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   41&lt;/span&gt;         &lt;span style="color: blue"&gt;WHERE&lt;/span&gt;(&lt;span style="color: blue"&gt;lower&lt;/span&gt;(&lt;span style="color: blue"&gt;Name&lt;/span&gt;) &lt;span style="color: blue"&gt;LIKE &lt;/span&gt;@LIKE_SEARCH &lt;span style="color: blue"&gt;OR &lt;/span&gt;&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   42&lt;/span&gt;             &lt;span style="color: blue"&gt;lower&lt;/span&gt;(ProductNumber) &lt;span style="color: blue"&gt;LIKE &lt;/span&gt;@LIKE_SEARCH)&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   43&lt;/span&gt;         ) &lt;span style="color: blue"&gt;AS &lt;/span&gt;ProductsWithRowNumber &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   44&lt;/span&gt;         &lt;span style="color: blue"&gt;WHERE &lt;/span&gt;RowRank &amp;gt; @StartRow &lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   45&lt;/span&gt;             &lt;span style="color: blue"&gt;AND &lt;/span&gt;RowRank &amp;lt;= @EndRow&lt;/p&gt;  &lt;p style="font-size: 10pt; background: white 0% 50%; margin: 0px; color: black; font-family: courier new; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;&lt;span style="color: rgb(43,145,175)"&gt;   46&lt;/span&gt; &lt;span style="color: blue"&gt;END &lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;This stored procedure will only work with SQL 2005 because of the over clause.&lt;/p&gt;  &lt;p&gt;The code to retrieve this was fairly straight forward if you want all the details grab the source code.  The main pain point that I found was this routine for manually mapping the results from the reader:&lt;/p&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: courier new"&gt;   &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   78&lt;/span&gt;         &lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; Product &lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   79&lt;/span&gt;             GetProductSummaryFromReader(&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   80&lt;/span&gt;                 IDataReader reader&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   81&lt;/span&gt;             )&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   82&lt;/span&gt;         {&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   83&lt;/span&gt;             Product product = &lt;span style="color: blue"&gt;new&lt;/span&gt; Product();&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   84&lt;/span&gt;             product.ProductID = &lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   85&lt;/span&gt;                 Convert.ToInt32(reader[&lt;span style="color: #a31515"&gt;"ProductId"&lt;/span&gt;]);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   86&lt;/span&gt;             product.Name = &lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   87&lt;/span&gt;                 Convert.ToString(reader[&lt;span style="color: #a31515"&gt;"Name"&lt;/span&gt;]);&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   88&lt;/span&gt;             product.ProductNumber = &lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   89&lt;/span&gt;                 Convert.ToString(&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   90&lt;/span&gt;                     reader[&lt;span style="color: #a31515"&gt;"ProductNumber"&lt;/span&gt;]&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   91&lt;/span&gt;                     );&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   92&lt;/span&gt;             &lt;span style="color: blue"&gt;return&lt;/span&gt; product;&lt;/p&gt;    &lt;p style="margin: 0px"&gt;&lt;span style="color: #2b91af"&gt;   93&lt;/span&gt;         }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;This code feels a little fragile with all the convert calls in there but at least it's all in one place.&lt;/p&gt;&lt;img src="http://blog.brownie.com.au/aggbug/12.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Andrew Browne</dc:creator>
            <guid>http://blog.brownie.com.au/archive/2007/11/26/datareaders-and-stored-procs---the-list.aspx</guid>
            <pubDate>Sun, 25 Nov 2007 23:25:54 GMT</pubDate>
            <comments>http://blog.brownie.com.au/archive/2007/11/26/datareaders-and-stored-procs---the-list.aspx#feedback</comments>
            <wfw:commentRss>http://blog.brownie.com.au/comments/commentRss/12.aspx</wfw:commentRss>
        </item>
        <item>
            <title>First Post!</title>
            <link>http://blog.brownie.com.au/archive/2007/11/18/first-post.aspx</link>
            <description>&lt;p&gt;This blog is primarily the result of the idea that "there should be a better way". I think most of us are constantly looking for faster/easier/more maintainable ways of doing things.&lt;/p&gt;  &lt;p&gt;In my case I am currently working in ASP.NET on public facing &lt;a href="http://www.getstarted.com.au"&gt;websites&lt;/a&gt;. After many conversations with colleagues about datasets/tableadapters vs everything else I decided that all the talk in the world wasn't going to get a well considered result. Over the last few months I have been exploring different .NET data access strategies.&lt;/p&gt;  &lt;p&gt;My method of comparison so far has been to use each of the technologies in the data layer for my very simple List/View/Add/Edit sample app. The example application is based on the AdventureWorks Cycles and I've named it &lt;strong&gt;Brownie's Bikes&lt;/strong&gt;.  The example is probably a bit simple at the moment but we'll fix that over time.&lt;/p&gt;  &lt;p&gt;My work is up at &lt;a title="http://code.google.com/p/browniesbikes/" href="http://code.google.com/p/browniesbikes/"&gt;http://code.google.com/p/browniesbikes/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;My plan is for my first few posts to compare the different strategies and technologies I have used to implement the data access in Brownie's Bikes.  While doing this work I have also become very excited by better ways of developing the UI and architecture for websites so expect some posts about these topics too.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; &lt;a href="http://www.jpboodhoo.com/blog/YouKnowAsMuchAsYouKnowRightNow.aspx"&gt;I only know as much as I know right now&lt;/a&gt;. I am very interested in better ways of doing things.  If you don't like my ideas I'd love to try yours. If you have a better idea or I am wrong let me know in an email/comment/link to your blog.  I have just finished the fourth data layer for my sample app and am planning more. I'm very open to trying any idea that looks reasonable.&lt;/p&gt;&lt;img src="http://blog.brownie.com.au/aggbug/5.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Andrew Browne</dc:creator>
            <guid>http://blog.brownie.com.au/archive/2007/11/18/first-post.aspx</guid>
            <pubDate>Sun, 18 Nov 2007 05:59:52 GMT</pubDate>
            <comments>http://blog.brownie.com.au/archive/2007/11/18/first-post.aspx#feedback</comments>
            <wfw:commentRss>http://blog.brownie.com.au/comments/commentRss/5.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>