<?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>ProgramGood.Net - Database</title>
    <link>http://www.programgood.net/</link>
    <description>The journey to becoming a great programmer</description>
    <language>en-us</language>
    <copyright>Dave Mateer</copyright>
    <lastBuildDate>Mon, 26 Jul 2010 00:46:41 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>davemateer@gmail.com</managingEditor>
    <webMaster>davemateer@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.programgood.net/Trackback.aspx?guid=72f0411a-9d6b-413e-b2b7-7e1d3b996b53</trackback:ping>
      <pingback:server>http://www.programgood.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.programgood.net/PermaLink,guid,72f0411a-9d6b-413e-b2b7-7e1d3b996b53.aspx</pingback:target>
      <dc:creator>Dave Mateer</dc:creator>
      <wfw:comment>http://www.programgood.net/CommentView,guid,72f0411a-9d6b-413e-b2b7-7e1d3b996b53.aspx</wfw:comment>
      <wfw:commentRss>http://www.programgood.net/SyndicationService.asmx/GetEntryCommentsRss?guid=72f0411a-9d6b-413e-b2b7-7e1d3b996b53</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"
</p>
        <p>
Be careful you are in the correct db!  I had to manually drop some tables in
the correct order due to FK’s
</p>
        <img width="0" height="0" src="http://www.programgood.net/aggbug.ashx?id=72f0411a-9d6b-413e-b2b7-7e1d3b996b53" />
      </body>
      <title>Delete All Tables in an MSSQL DB</title>
      <guid isPermaLink="false">http://www.programgood.net/PermaLink,guid,72f0411a-9d6b-413e-b2b7-7e1d3b996b53.aspx</guid>
      <link>http://www.programgood.net/2010/07/26/DeleteAllTablesInAnMSSQLDB.aspx</link>
      <pubDate>Mon, 26 Jul 2010 00:46:41 GMT</pubDate>
      <description>&lt;p&gt;
EXEC sp_MSforeachtable @command1 = &amp;quot;DROP TABLE ?&amp;quot;
&lt;/p&gt;
&lt;p&gt;
Be careful you are in the correct db!&amp;#160; I had to manually drop some tables in
the correct order due to FK’s
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.programgood.net/aggbug.ashx?id=72f0411a-9d6b-413e-b2b7-7e1d3b996b53" /&gt;</description>
      <comments>http://www.programgood.net/CommentView,guid,72f0411a-9d6b-413e-b2b7-7e1d3b996b53.aspx</comments>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://www.programgood.net/Trackback.aspx?guid=1331c215-9394-48c3-922e-b705c2a62ff3</trackback:ping>
      <pingback:server>http://www.programgood.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.programgood.net/PermaLink,guid,1331c215-9394-48c3-922e-b705c2a62ff3.aspx</pingback:target>
      <dc:creator>Dave Mateer</dc:creator>
      <wfw:comment>http://www.programgood.net/CommentView,guid,1331c215-9394-48c3-922e-b705c2a62ff3.aspx</wfw:comment>
      <wfw:commentRss>http://www.programgood.net/SyndicationService.asmx/GetEntryCommentsRss?guid=1331c215-9394-48c3-922e-b705c2a62ff3</wfw:commentRss>
      <title>Test Driven Development in .NET - DAL (Ch5)</title>
      <guid isPermaLink="false">http://www.programgood.net/PermaLink,guid,1331c215-9394-48c3-922e-b705c2a62ff3.aspx</guid>
      <link>http://www.programgood.net/2009/10/20/TestDrivenDevelopmentInNETDALCh5.aspx</link>
      <pubDate>Tue, 20 Oct 2009 01:03:44 GMT</pubDate>
      <description>From the nbdn course, I had some interesting code I'd like to test.  Just the business logic really, no DAL nor UI.  As I wanted to make a full application, the first though was to make a DAL which talked to a text file, or just some dummy data.  How to do this well?  De-coupled.  Tried to use poor mans dependency injection, and got confused.  So I had a coffee, and bought this book.  Because it had an end to end example of a testable application.  It uses .net1.1 mostly (which is good as there are no language constructs to learn)&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.programgood.net/content/binary/tdd.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
Some good introduction to refactorings, and unit testing. The main meat of the book
is an example called MediaLibrary (music recordings). Chapter 5 started with testing
the DAL. 
&lt;br&gt;
&lt;br&gt;
Here are the first tests. Am showing nunit test runner.. mostly I use testdriven.net,
and have setup ctrl alt shft t to run tests.&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.programgood.net/content/binary/screen123.gif" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
for source control I'm using git, and have coupled up with gvim as text editor. And
linked in beyond compare for a merge tool.&lt;br&gt;
&lt;br&gt;
The book uses Strongly Typed Datasets, which were the 'star of the show' in the .net1.0
release. By writing the sql, and having intellisense have autoproperties, this saves
writing boiler plate code.&lt;br&gt;
&lt;br&gt;
I learned about DataSets.. here is my edit (from wikipedia)..http://en.wikipedia.org/wiki/ADO.NET#DataSets&lt;br&gt;
&lt;p&gt;
ADO.NET consists of two primary parts:
&lt;/p&gt;
&lt;h3&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline" id="Data_provider"&gt;Data
provider&lt;/span&gt;
&lt;/h3&gt;
&lt;p&gt;
These classes provide access to a data source, such as a &lt;a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" title="Microsoft SQL Server"&gt;Microsoft
SQL Server&lt;/a&gt;. Each data source has its own set of provider objects, but they each
have a common set of utility classes:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://en.wikipedia.org/wiki/Database_Connection" title="Database Connection" class="mw-redirect"&gt;Connection&lt;/a&gt;:
Provides a connection used to communicate with the data source. 
&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://en.wikipedia.org/wiki/Command" title="Command"&gt;Command&lt;/a&gt;: Used to
perform some action on the data source, such as reading, updating, or deleting relational
data.&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://en.wikipedia.org/wiki/Parameter" title="Parameter"&gt;Parameter&lt;/a&gt;:
Describes a single parameter to a command. A common example is a parameter to a &lt;a href="http://en.wikipedia.org/wiki/Stored_procedure" title="Stored procedure"&gt;stored
procedure&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://en.wikipedia.org/wiki/DataAdapter" title="DataAdapter"&gt;DataAdapter&lt;/a&gt;:
A bridge used to transfer data between a Data source and a DataSet object (see below).&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://en.wikipedia.org/wiki/DataReader" title="DataReader"&gt;DataReader&lt;/a&gt;:
Used to efficiently process a large list of results one record at a time. It allows
records to be accessed in a read-only, forward-only mode, i.e., records have to be
accessed in sequential order; they can neither be randomly accessed nor can a record
which has been processed previously be accessed again.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span class="mw-headline" id="DataSets"&gt;DataSets&lt;/span&gt;
&lt;/h3&gt;
&lt;p&gt;
DataSet objects, a group of classes describing a simple in-memory &lt;a href="http://en.wikipedia.org/wiki/Relational_database" title="Relational database"&gt;relational
database&lt;/a&gt;, 
&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
A &lt;b&gt;DataSet&lt;/b&gt; object represents a &lt;a href="http://en.wikipedia.org/wiki/Logical_schema" title="Logical schema"&gt;schema&lt;/a&gt; (either
an entire database or a subset of one). It can contain tables and relationships between
those tables. 
&lt;ul&gt;
&lt;li&gt;
A &lt;b&gt;DataTable&lt;/b&gt; object represents a single table in the database. It has a name,
rows, and columns. 
&lt;ul&gt;
&lt;li&gt;
A &lt;b&gt;DataView&lt;/b&gt; object overlays a DataTable and sorts the data (much like an &lt;a href="http://en.wikipedia.org/wiki/SQL" title="SQL"&gt;SQL&lt;/a&gt; "&lt;a href="http://en.wikipedia.org/wiki/Order_by" title="Order by" class="mw-redirect"&gt;order
by&lt;/a&gt;" clause) and filters the records (much like an SQL "&lt;a href="http://en.wikipedia.org/wiki/Where_%28SQL%29" title="Where (SQL)"&gt;where&lt;/a&gt;"
clause) if a filter is set. An in-memory index is used to facilitate these operations.
All DataTables have a default filter, while any number of additional DataViews can
be defined, reducing interaction with the underlying database and thus improving performance. 
&lt;ul&gt;
&lt;li&gt;
A &lt;b&gt;DataColumn&lt;/b&gt; represents a column of the table, including its name and type.&lt;/li&gt;
&lt;li&gt;
A &lt;b&gt;DataRow&lt;/b&gt; object represents a single row in the table; it allows reading and
updating of values in that row, likewise retrieving any rows that are related to it
through a primary-key foreign-key relationship.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
VS has a nice editor:&lt;br&gt;
&lt;img src="http://www.programgood.net/content/binary/screen12345.gif" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Once I spiked up what datasets were (in simpleDatabaseTests.cs).. used this for reference:
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson05.asp&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt; [Test] &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; put_data_into_a_dataset()
{ DataSet dataset &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; DataSet();
SqlDataAdapter data_adapter &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; SqlDataAdapter(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"select
id, name from Artist"&lt;/span&gt;, connection); SqlCommandBuilder sql_command_builder &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; SqlCommandBuilder(data_adapter);
data_adapter.Fill(dataset, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Artist"&lt;/span&gt;);
Assert.IsNotNull(dataset); DataTable data_table &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; dataset.Tables[0]; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;for&lt;/span&gt; (&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt; i &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt;&lt; data_table.Rows.Count; i++)
            {
                DataRow data_row &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt; 0;
i =&lt;/span&gt; data_table.Rows[i]; Console.Out.Write(data_row[&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"id"&lt;/span&gt;] &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"
"&lt;/span&gt;); Console.Out.WriteLine(data_row[&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"name"&lt;/span&gt;]);
} }&gt;&lt;/pre&gt;
&lt;br&gt;
The example I'm working through uses a Table Data Gateway Pattern for the DAL. 
&lt;br&gt;
&lt;br&gt;
http://martinfowler.com/eaaCatalog/tableDataGateway.html&lt;br&gt;
"A Table Data Gateway holds all the SQL for accessing a single table or view: selects,
inserts, updates, and deletes. Other code calls its methods for all interaction with
the database."&lt;br&gt;
&lt;br&gt;
Lets take an example of ArtistFixture.cs which tests ArtistGateway.cs&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;[TestFixture] &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; ArtistFixture
{ &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;readonly&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; artistName &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Artist"&lt;/span&gt;;
SqlConnection connection; ArtistGateway gateway; RecordingDataSet recordingDataSet; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;long&lt;/span&gt; artistId;
[SetUp] &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; setup_and_open_connection_pass_to_gateway_setup_data_set()
{ connection &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; SqlConnection(ConfigurationSettings.AppSettings.Get(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Catalog.Connection"&lt;/span&gt;));
connection.Open(); recordingDataSet &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; RecordingDataSet();
gateway &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; ArtistGateway(connection); &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//
insert a new artist getting its ID from the database&lt;/span&gt; artistId &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; gateway.Insert(recordingDataSet,
artistName); } [Test] &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; RetrieveArtistFromDatabase()
{ &lt;span style="color: Green; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;//
create new RDS, use same gateway.&lt;/span&gt; RecordingDataSet loadedFromDB &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; RecordingDataSet();
RecordingDataSet.Artist loadedArtist &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; gateway.FindById(artistId,
loadedFromDB); Assert.AreEqual(artistId, loadedArtist.Id); Assert.AreEqual(artistName,
loadedArtist.Name); }&lt;/span&gt;&lt;/pre&gt;Here is part of ArtistGateway.cs.. gateway is newed
up with a connection passed in.. then only in Insert is it passed in a strongly typed
RecordingDataSet, which has all the SQL in it which has been auto-genned.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; ArtistGateway&lt;br&gt;
{&lt;br&gt;
SqlDataAdapter adapter;&lt;br&gt;
SqlConnection connection;&lt;br&gt;
SqlCommand command;&lt;br&gt;
SqlCommandBuilder builder;&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; ArtistGateway(SqlConnection
connection)&lt;br&gt;
{&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.connection &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; connection;&lt;br&gt;
&lt;br&gt;
command &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; SqlCommand(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"select
id, name from artist where id = @id"&lt;/span&gt;,connection);&lt;br&gt;
command.Parameters.Add(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"@id"&lt;/span&gt;,
SqlDbType.BigInt);&lt;br&gt;
&lt;br&gt;
adapter &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; SqlDataAdapter(command);&lt;br&gt;
builder &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; SqlCommandBuilder(adapter);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; RecordingDataSet.Artist
FindById(&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;long&lt;/span&gt; artistId,
RecordingDataSet recordingDataSet)&lt;br&gt;
{&lt;br&gt;
command.Parameters[&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"@id"&lt;/span&gt;].Value &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; artistId;&lt;br&gt;
adapter.Fill(recordingDataSet, recordingDataSet.Artists.TableName);&lt;br&gt;
DataRow[] rows &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; recordingDataSet.Artists.Select(String.Format(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"id={0}"&lt;/span&gt;,
artistId));&lt;br&gt;
&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt;&lt; 1) &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt; (rows.Length
return&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;null&lt;/span&gt;;&lt;br&gt;
&lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; (RecordingDataSet.Artist)
rows[0];&lt;br&gt;
}&lt;br&gt;
&gt;Class Diagram done in VS2008 with the Class Designer Powertoy http://www.codeplex.com/modeling&lt;br&gt;
To get the blue lines go to Class Diagram, Filter Lines, Show All Associations.&lt;br&gt;
&lt;img src="http://www.programgood.net/content/binary/screen123456.gif" border="0"&gt;
&lt;br&gt;
&lt;/pre&gt;Sequence diagram done in Visio: (hmm - this is a bit complex... I prefer the
class diagram above with notes)&lt;br&gt;
&lt;img src="http://www.programgood.net/content/binary/sequenceArtistFixture.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
Genre was next, then the rest. Then relationships between objects eg ReviewReviewer..
just testing the test data we create comes back: Have abstracted out some of the setup
code into ConnectionFixture.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt; [TestFixture] &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;class&lt;/span&gt; ReviewReviewerFixture
: ConnectionFixture { [Test] &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; ReviewerId()
{ RecordingDataSet recordingDataSet &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; RecordingDataSet();
ReviewGateway reviewGateway &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; ReviewGateway(Connection); &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;long&lt;/span&gt; reviewId &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; reviewGateway.Insert(recordingDataSet,
1, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Review
Content"&lt;/span&gt;); ReviewerGateway reviewerGateway &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; ReviewerGateway(Connection); &lt;span style="color: Blue; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;long&lt;/span&gt; reviewerId &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; reviewerGateway.Insert(recordingDataSet, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Reviewer
Name"&lt;/span&gt;); RecordingDataSet.Review review &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; reviewGateway.FindById(reviewId,
recordingDataSet); review.ReviewerId &lt;span style="color: Red; background-color: Transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; reviewerId;
reviewGateway.Update(recordingDataSet); Assert.AreEqual(reviewerId, review.Reviewer.Id);
reviewGateway.Delete(recordingDataSet, reviewId); reviewerGateway.Delete(recordingDataSet,
reviewerId); } }&lt;/span&gt;&lt;/pre&gt;The hardest test is RecordingGateway, as it depends on
all the other 'tables'. To simplify, we abstract out the insert/del of test data to
RecordingBuilder.cs.&lt;br&gt;
&lt;br&gt;
The last class is Catalog, which is the only class that will be called from the Service
layer. In Catalog we have FindByRecordingId, which returns a RecordingDataSet.Recording
(so all the data associated with this recordingId).&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.programgood.net/content/binary/DALOverview.jpg" border="0"&gt;
&lt;br&gt;
&lt;br&gt;
In summary we have done this of the overall structure of the APP:&lt;br&gt;
&lt;br&gt;
&lt;img src="http://www.programgood.net/content/binary/DALDiag.gif" border="0"&gt;&lt;img width="0" height="0" src="http://www.programgood.net/aggbug.ashx?id=1331c215-9394-48c3-922e-b705c2a62ff3" /&gt;</description>
      <comments>http://www.programgood.net/CommentView,guid,1331c215-9394-48c3-922e-b705c2a62ff3.aspx</comments>
      <category>Database</category>
      <category>Object Oriented Programming</category>
      <category>Patterns</category>
      <category>Testing</category>
    </item>
  </channel>
</rss>