<?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>.Hibri - .Net Data</title>
    <link>http://www.hibri.net/</link>
    <description>Thoughts on the craft of building software</description>
    <language>en-gb</language>
    <copyright>Hibri Marzook</copyright>
    <lastBuildDate>Wed, 10 Jun 2009 17:28:07 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>hibri@hibri.net</managingEditor>
    <webMaster>hibri@hibri.net</webMaster>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=3e9fe7f4-3d15-4ced-bcbf-d4abc472be99</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,3e9fe7f4-3d15-4ced-bcbf-d4abc472be99.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,3e9fe7f4-3d15-4ced-bcbf-d4abc472be99.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=3e9fe7f4-3d15-4ced-bcbf-d4abc472be99</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.nhprof.com">The NHibernate Profiler</a> is a pretty cool tool.
If you are using NHibernate and want to see how your application/website uses NHibernate
this is what you need. 
</p>
        <p>
But, why wait till you use the whole application to start using the profiler. Why
not use it when writing  writing tests , while building your mappings and when
building your NHibernate queries. It’s really easy to do this.
</p>
        <p>
First, get the NHibernate profiler from <a href="http://www.nhprof.com">www.nhprof.com</a>.
Extract the contents to a location. From your test project, add a reference to <strong>HibernatingRhinos.NHibernate.Profiler.Appender.dll</strong> in
the NHProf package.
</p>
        <p>
This is my small test class.
</p>
        <pre class="csharpcode"> [TestFixture]
    <span class="kwrd">public</span><span class="kwrd">class</span> EpisodeTests
: BaseTest { [SetUp] <span class="kwrd">public</span><span class="kwrd">override</span><span class="kwrd">void</span> SetUp()
{ <span class="kwrd">base</span>.SetUp(); ActiveRecordStarter.Initialize(<span class="kwrd">typeof</span>(Episode).Assembly, <span class="kwrd">new</span> XmlConfigurationSource(<span class="str">"activerecord.xml"</span>));
} [Test] <span class="kwrd">public</span><span class="kwrd">void</span> CanPersistTitle()
{ Episode episode = <span class="kwrd">new</span> Episode(); <span class="kwrd">string</span> expectedTitle
= <span class="str">"Dr Who and the Daleks"</span>; episode.Title = expectedTitle;
episode.Save(); Guid savedEpisodeId = episode.Id; episode = ActiveRecordBase&lt;Episode&gt;.Find(savedEpisodeId);
Assert.That(episode.Title, Is.EqualTo(expectedTitle)); } }</pre>
        <p>
        </p>
        <pre class="csharpcode"> </pre>
        <p>
        </p>
        <p>
I’m using Castle ActiveRecord (which uses NHibernate behind the scenes) to demonstrate
this. To enable NHProf to profile the test, add a static constructor to the super
class , <strong>BaseTest</strong>. In the static constructor, add the following code.
</p>
        <pre class="csharpcode">HibernatingRhinos.NHibernate.Profiler.Appender.NHibernateProfiler.Initialize();</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>
Go to where you extracted NHProf and run the profiler exe. Run the test and watch
the magic.
</p>
        <p>
          <a href="http://www.hibri.net/content/binary/WindowsLiveWriter/UsingNHibernateProfilerwithdatabaseinte_FDC4/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.hibri.net/content/binary/WindowsLiveWriter/UsingNHibernateProfilerwithdatabaseinte_FDC4/image_thumb.png" width="659" height="509" />
          </a>
        </p>
        <p>
NHProf is now profiling your integration tests. You can leave this running in the
background while you are working on the tests. 
</p>
        <p>
You get immediate feedback NHibernate best practice violations, and you can<em><strong> fix
them while writing tests</strong>. </em>You don’t have to wait till deployment to
profile your code. Although this doesn’t give the whole picture of how your application
is using NHibernate , you still can fix many things early. I highly recommend running
NHProf while running automated acceptance test scenarios.
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3916a100-f10a-4ead-859e-089ef55b9710" class="wlWriterEditableSmartContent">Technorati
Tags: <a href="http://technorati.com/tags/NHibernate" rel="tag">NHibernate</a>,<a href="http://technorati.com/tags/TDD" rel="tag">TDD</a></div>
        <p>
 
</p>
        <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>
      </body>
      <title>Using NHibernate Profiler with database integration tests.</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,3e9fe7f4-3d15-4ced-bcbf-d4abc472be99.aspx</guid>
      <link>http://www.hibri.net/2009/06/10/UsingNHibernateProfilerWithDatabaseIntegrationTests.aspx</link>
      <pubDate>Wed, 10 Jun 2009 17:28:07 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.nhprof.com"&gt;The NHibernate Profiler&lt;/a&gt; is a pretty cool tool.
If you are using NHibernate and want to see how your application/website uses NHibernate
this is what you need. 
&lt;/p&gt;
&lt;p&gt;
But, why wait till you use the whole application to start using the profiler. Why
not use it when writing&amp;nbsp; writing tests , while building your mappings and when
building your NHibernate queries. It’s really easy to do this.
&lt;/p&gt;
&lt;p&gt;
First, get the NHibernate profiler from &lt;a href="http://www.nhprof.com"&gt;www.nhprof.com&lt;/a&gt;.
Extract the contents to a location. From your test project, add a reference to &lt;strong&gt;HibernatingRhinos.NHibernate.Profiler.Appender.dll&lt;/strong&gt; in
the NHProf package.
&lt;/p&gt;
&lt;p&gt;
This is my small test class.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt; [TestFixture]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; EpisodeTests
: BaseTest { [SetUp] &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetUp()
{ &lt;span class="kwrd"&gt;base&lt;/span&gt;.SetUp(); ActiveRecordStarter.Initialize(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Episode).Assembly, &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlConfigurationSource(&lt;span class="str"&gt;"activerecord.xml"&lt;/span&gt;));
} [Test] &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CanPersistTitle()
{ Episode episode = &lt;span class="kwrd"&gt;new&lt;/span&gt; Episode(); &lt;span class="kwrd"&gt;string&lt;/span&gt; expectedTitle
= &lt;span class="str"&gt;"Dr Who and the Daleks"&lt;/span&gt;; episode.Title = expectedTitle;
episode.Save(); Guid savedEpisodeId = episode.Id; episode = ActiveRecordBase&amp;lt;Episode&amp;gt;.Find(savedEpisodeId);
Assert.That(episode.Title, Is.EqualTo(expectedTitle)); } }&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
I’m using Castle ActiveRecord (which uses NHibernate behind the scenes) to demonstrate
this. To enable NHProf to profile the test, add a static constructor to the super
class , &lt;strong&gt;BaseTest&lt;/strong&gt;. In the static constructor, add the following code.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;HibernatingRhinos.NHibernate.Profiler.Appender.NHibernateProfiler.Initialize();&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;
Go to where you extracted NHProf and run the profiler exe. Run the test and watch
the magic.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.hibri.net/content/binary/WindowsLiveWriter/UsingNHibernateProfilerwithdatabaseinte_FDC4/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.hibri.net/content/binary/WindowsLiveWriter/UsingNHibernateProfilerwithdatabaseinte_FDC4/image_thumb.png" width="659" height="509"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
NHProf is now profiling your integration tests. You can leave this running in the
background while you are working on the tests. 
&lt;/p&gt;
&lt;p&gt;
You get immediate feedback NHibernate best practice violations, and you can&lt;em&gt;&lt;strong&gt; fix
them while writing tests&lt;/strong&gt;. &lt;/em&gt;You don’t have to wait till deployment to
profile your code. Although this doesn’t give the whole picture of how your application
is using NHibernate , you still can fix many things early. I highly recommend running
NHProf while running automated acceptance test scenarios.
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3916a100-f10a-4ead-859e-089ef55b9710" class="wlWriterEditableSmartContent"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/NHibernate" rel="tag"&gt;NHibernate&lt;/a&gt;,&lt;a href="http://technorati.com/tags/TDD" rel="tag"&gt;TDD&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&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;</description>
      <comments>http://www.hibri.net/CommentView,guid,3e9fe7f4-3d15-4ced-bcbf-d4abc472be99.aspx</comments>
      <category>.Net Data</category>
      <category>Agile</category>
      <category>NHibernate</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=225e16f1-02f4-4424-831d-836e764f4c71</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,225e16f1-02f4-4424-831d-836e764f4c71.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,225e16f1-02f4-4424-831d-836e764f4c71.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=225e16f1-02f4-4424-831d-836e764f4c71</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Pramod Sadalage, has written an article on Behaviour Driven DB development. <a href="http://www.methodsandtools.com/archive/archive.php?id=78">http://www.methodsandtools.com/archive/archive.php?id=78</a>.
</p>
        <p>
He writes about adding behaviour to the domain model and how that behaviour is translates
into database objects, with tests. In the project I'm working on, which driven by
a Web UI I use the UI behaviour to build the presenter and  through this add
behaviour to the domain model. It's at the last stage that I add the persistance,
through Nhibernate. 
</p>
      </body>
      <title>Behaviour Driven Database Development (BDDD)</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,225e16f1-02f4-4424-831d-836e764f4c71.aspx</guid>
      <link>http://www.hibri.net/2008/12/27/BehaviourDrivenDatabaseDevelopmentBDDD.aspx</link>
      <pubDate>Sat, 27 Dec 2008 11:20:26 GMT</pubDate>
      <description>&lt;p&gt;
Pramod Sadalage, has written an article on Behaviour Driven DB development. &lt;a href="http://www.methodsandtools.com/archive/archive.php?id=78"&gt;http://www.methodsandtools.com/archive/archive.php?id=78&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
He writes about adding behaviour to the domain model and how that behaviour is translates
into database objects, with tests. In the project I'm working on, which driven by
a Web UI I use the UI behaviour to build the presenter and&amp;#160; through this add
behaviour to the domain model. It's at the last stage that I add the persistance,
through Nhibernate. 
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,225e16f1-02f4-4424-831d-836e764f4c71.aspx</comments>
      <category>.Net Data</category>
      <category>Agile</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=b4bc272c-fb18-4d32-be2b-923afc493523</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,b4bc272c-fb18-4d32-be2b-923afc493523.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,b4bc272c-fb18-4d32-be2b-923afc493523.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=b4bc272c-fb18-4d32-be2b-923afc493523</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Many web applications have a back end "admin" pages to manage tables in the database. 
These pages exist solely to perform CRUD operations against a single table. Sometimes
with a bit of validation.
</p>
        <p>
It is tedious work if you have to create and write the same code  for each table
and to maintain them. To make this task somewhat easier, there are solutions that
look at the database structure, and generate the data access code and the asp.net
pages.
</p>
        <p>
The latest and greatest of them is <a href="http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx" target="_blank">ASP
.Net Dynamic data</a>. This uses LINQ to SQL for data access. Its quite easy to get
a site up and running using this.
</p>
        <p>
          <a href="http://www.castleproject.org/monorail/documentation/v1rc2/integration/arscaffold.html" target="_blank">Mono
Rail</a> has an ActiveRecord scaffold.  This uses Castle ActiveRecord and Nhibernate
to generate the scaffold. However, this doesn't generate the database to object model
mapping automatically.  Classes that inherent from an ActiveRecord base have
to be created first. Fields and relationships have to be defined in code. When this
is done its all a breeze. Its a good way to get to grips with MonoRail.
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.subsonicproject.com/" target="_blank">Subsonic</a> which I'm using
on a project now, has two methods of operation. It has a set of scaffold controls
which you can use on any asp.net pages to get CRUD functionality, and it also has
the option to generate the asp.net pages and the data classes. The data classes generated
by subsonic use the active record pattern too. The code generated by subsonic can
be modified if you need to do so. After the code is generated these are normal asp.net
pages to which you can add validation, combine with master pages etc..
</p>
        <p>
Subsonic and Asp.Net dynamic data offer the quickest way to get up and running. 
Subsonic and MonoRail offer the possibility to extend the application when things
get more complex. The data classes generated can be reused when the application grows
beyond a simple prototype or admin section.
</p>
      </body>
      <title>Scaffolding with ASP.Net</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,b4bc272c-fb18-4d32-be2b-923afc493523.aspx</guid>
      <link>http://www.hibri.net/2008/01/24/ScaffoldingWithASPNet.aspx</link>
      <pubDate>Thu, 24 Jan 2008 21:53:00 GMT</pubDate>
      <description>&lt;p&gt;
Many web applications have a back end "admin" pages to manage tables in the database.&amp;nbsp;
These pages exist solely to perform CRUD operations against a single table. Sometimes
with a bit of validation.
&lt;/p&gt;
&lt;p&gt;
It is tedious work if you have to create and write the same code&amp;nbsp; for each table
and to maintain them. To make this task somewhat easier, there are solutions that
look at the database structure, and generate the data access code and the asp.net
pages.
&lt;/p&gt;
&lt;p&gt;
The latest and greatest of them is &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx" target="_blank"&gt;ASP
.Net Dynamic data&lt;/a&gt;. This uses LINQ to SQL for data access. Its quite easy to get
a site up and running using this.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.castleproject.org/monorail/documentation/v1rc2/integration/arscaffold.html" target="_blank"&gt;Mono
Rail&lt;/a&gt; has an ActiveRecord scaffold.&amp;nbsp; This uses Castle ActiveRecord and Nhibernate
to generate the scaffold. However, this doesn't generate the database to object model
mapping automatically.&amp;nbsp; Classes that inherent from an ActiveRecord base have
to be created first. Fields and relationships have to be defined in code. When this
is done its all a breeze. Its a good way to get to grips with MonoRail.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.subsonicproject.com/" target="_blank"&gt;Subsonic&lt;/a&gt; which I'm using
on a project now, has two methods of operation. It has a set of scaffold controls
which you can use on any asp.net pages to get CRUD functionality, and it also has
the option to generate the asp.net pages and the data classes. The data classes generated
by subsonic use the active record pattern too. The code generated by subsonic can
be modified if you need to do so. After the code is generated these are normal asp.net
pages to which you can add validation, combine with master pages etc..
&lt;/p&gt;
&lt;p&gt;
Subsonic and Asp.Net dynamic data offer the quickest way to get up and running.&amp;nbsp;
Subsonic and MonoRail offer the possibility to extend the application when things
get more complex. The data classes generated can be reused when the application grows
beyond a simple prototype or admin section.
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,b4bc272c-fb18-4d32-be2b-923afc493523.aspx</comments>
      <category>.Net Data</category>
      <category>.Net Web</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=ebeff4d9-b395-48a2-aa57-bbc957717c5f</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,ebeff4d9-b395-48a2-aa57-bbc957717c5f.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,ebeff4d9-b395-48a2-aa57-bbc957717c5f.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=ebeff4d9-b395-48a2-aa57-bbc957717c5f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was playing with Redgate's SQL Dependency tracker yesterday. The balloon tree view
sort of shows how modular the db design is. I'm working on a project where I'm implementing
"pluggable" modules of functionality.
</p>
        <p>
The two circular clusters at the top left corner are the db objects for the module
I'm working on. The view shows how the cluster relates to the ASP .Net membership
provider tables. The clusters which go diagonally across the view are the aspnet db
objects.
</p>
        <p>
          <a href="http://www.hibri.net/content/binary/WindowsLiveWriter/SQLDependencyTracker_93E5/image_1.png" atomicselection="true">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="392" alt="image" src="http://www.hibri.net/content/binary/WindowsLiveWriter/SQLDependencyTracker_93E5/image_thumb_1.png" width="590" border="0" />
          </a>
        </p>
      </body>
      <title>SQL Dependency Tracker</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,ebeff4d9-b395-48a2-aa57-bbc957717c5f.aspx</guid>
      <link>http://www.hibri.net/2007/06/26/SQLDependencyTracker.aspx</link>
      <pubDate>Tue, 26 Jun 2007 09:31:11 GMT</pubDate>
      <description>&lt;p&gt;
I was playing with Redgate's SQL Dependency tracker yesterday. The balloon tree view
sort of shows how modular the db design is. I'm working on a project where I'm implementing
"pluggable" modules of functionality.
&lt;/p&gt;
&lt;p&gt;
The two circular clusters at the top left corner&amp;nbsp;are the db objects for the module
I'm working on. The view shows how the cluster relates to the ASP .Net membership
provider tables. The clusters which go diagonally across the view are the aspnet db
objects.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.hibri.net/content/binary/WindowsLiveWriter/SQLDependencyTracker_93E5/image_1.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="392" alt="image" src="http://www.hibri.net/content/binary/WindowsLiveWriter/SQLDependencyTracker_93E5/image_thumb_1.png" width="590" border="0"&gt;&lt;/a&gt;
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,ebeff4d9-b395-48a2-aa57-bbc957717c5f.aspx</comments>
      <category>.Net Data</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=7dad8d70-ef72-4692-b0e5-59208d13912d</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,7dad8d70-ef72-4692-b0e5-59208d13912d.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,7dad8d70-ef72-4692-b0e5-59208d13912d.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=7dad8d70-ef72-4692-b0e5-59208d13912d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://msdn2.microsoft.com/en-us/library/9a4kyhcx.aspx">The Object Data Source
(ODS)</a> helps you expose your business objects, to provide data to databound controls such
as the GridView, DetailsView and many other data bound controls.
</p>
        <p>
Compared to the other data sources like the DataTable and DataSet, the ODS does require
some work to achieve the same functionality. The main advantage of the ODS is that
it allows you to maintain your layers, without polluting your presentation layer with
data code.
</p>
        <p>
To start off,  drag and drop the ODS control to a web form. Set the TypeName
property to the business object you want to work with. For example, if we have a BO
named Employees in the TimeTracker namespace, this will be TimeTracker.Employee.
</p>
        <p>
          <strong>Selecting</strong>
          <br />
 A common scenario is to display the a list of records. Say we want to display
the list of all employees in a GridView. To retrieve the records, the Employee object
needs a GetEmployees static method that will retrieve  all the employees from
the DB.  Set the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectmethod.aspx">SelectMethod</a> property
of the ODS to GetEmployees. Now bind the ODS to the GridView just like any other data
source.
</p>
        <p>
At runtime the ODS uses reflection to find the GetEmployees method and invokes it.
</p>
        <p>
          <strong>Paging and filtering</strong>
        </p>
        <p>
Filtering Employee objects is as easy as adding a new method to your Employee object.
If we want to select Employees by department, the Employee object should have a static method 
</p>
        <p>
GetEmployees(string department)
</p>
        <p>
In the properties window of the ODS, add the department parameter to the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectparameters.aspx">SelectParameters</a> collection.
You can set a default value to it, and this is where things get real easy. You can
bind the parameter to a control on your web form ( like a DropDownList) , a Session
variable and even a query string parameter.  Adding  filtering functionality
is simple as that. You can do the same programmatically by adding Parameters to the
SelectParameters collection. Be sure to clear the collection before you add a parameter(
or check if the parameter exists).
</p>
        <p>
Paging is where working with the ODS gets a bit complicated. To enable paging ( in
conjunction with the GridView) set the EnablePaging property to true. The Employee
object too, needs to have methods to support paging. 
</p>
        <p>
When paging is enabled, the ODS calls the GetEmployee method with two extra parameters.
by default the parameters are <strong>startRowIndex</strong> and <strong>maximumRows</strong>.
These can be changed by setting the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.startrowindexparametername.aspx">StartRowIndexParameterName</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.maximumrowsparametername.aspx">MaximumRowsParameterName</a> properties.
</p>
        <p>
Now we need a GetEmployees method with the signature like<br />
GetEmployees(int startRowIndex,int maxiumRows)<br />
To support filtering it will have to be GetEmployees(string department ,int startRowIndex,int
maxiumRows)
</p>
        <p>
The maximumRows parameter, will have the value of how many rows to display per page.
This will have the value of the PageSize property of the GridView. The startRowIndex
will contain the the index of the current page. This can be the starting row index
of the current page of records. See <a href="http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx">here
for more on how to pass these on to an SQL query</a>. 
</p>
        <p>
In addition to this the ODS needs another method that is set by the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectcountmethod.aspx">SelectCountMethod</a> property.
This is invoked to find out the total number of rows available. So we need another
static method in our Employee object. GetEmployeesCount() .If the total number of
rows is 100, and you have a page size of 20. The GetEmployees count method should
return 100, so that the ODS can tell the GridView, how many pager links to display.
I usually return this as an out parameter from the stored procedure that retrieves
the paged results.
</p>
        <p>
          <strong>Inserting, Editing and Deleting</strong>
        </p>
        <p>
Inserting, editing and deleting is pretty easy. All you will again is to have the
appropriate static methods in the Employee object.<br />
AddEmployee(Employee e)<br />
UpdateEmployee(Employee e)<br />
DeleteEmployee(Emplyee e).
</p>
        <p>
Set the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.insertmethod.aspx">InsertMethod</a> , <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.updatemethod.aspx">UpdateMethod</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.deletemethod.aspx">DeleteMethod</a> properties
accordingly. All these method can be configured with parameters like the SelectMethod.
However, setting the <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.dataobjecttypename.aspx">DataObjectTypeName</a> property
to the Employee object will reduce a lot of the hassle by passing Employee objects
to the Add,Update and DeleteMethods.
</p>
      </body>
      <title>Working with the Object Data Source</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,7dad8d70-ef72-4692-b0e5-59208d13912d.aspx</guid>
      <link>http://www.hibri.net/2006/11/25/WorkingWithTheObjectDataSource.aspx</link>
      <pubDate>Sat, 25 Nov 2006 13:33:32 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/9a4kyhcx.aspx"&gt;The Object Data Source
(ODS)&lt;/a&gt; helps you expose your business objects, to provide data to databound controls&amp;nbsp;such
as&amp;nbsp;the GridView, DetailsView and many other data bound controls.
&lt;/p&gt;
&lt;p&gt;
Compared to the other data sources like the DataTable and DataSet, the ODS does require
some work to achieve the same functionality. The main advantage of the ODS is that
it allows you to maintain your layers, without polluting your presentation layer with
data code.
&lt;/p&gt;
&lt;p&gt;
To start off,&amp;nbsp; drag and drop the ODS control to a web form. Set the TypeName
property to the business object you want to work with. For example, if we have a&amp;nbsp;BO
named Employees in the TimeTracker namespace, this will be&amp;nbsp;TimeTracker.Employee.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Selecting&lt;/strong&gt;
&lt;br&gt;
&amp;nbsp;A common scenario is to display the a list of records. Say we want to display
the list of all employees in a GridView. To retrieve the records, the Employee object
needs a GetEmployees static method that will retrieve&amp;nbsp; all the employees from
the DB.&amp;nbsp; Set the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectmethod.aspx"&gt;SelectMethod&lt;/a&gt; property
of the ODS to GetEmployees. Now bind the ODS to the GridView just like any other data
source.
&lt;/p&gt;
&lt;p&gt;
At runtime the ODS uses reflection to find the GetEmployees method and invokes it.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Paging and filtering&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Filtering Employee objects is as easy as adding a new method to your Employee object.
If we want to select Employees by department, the Employee object should have a static&amp;nbsp;method 
&lt;/p&gt;
&lt;p&gt;
GetEmployees(string department)
&lt;/p&gt;
&lt;p&gt;
In the properties window of the ODS, add the department parameter to the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectparameters.aspx"&gt;SelectParameters&lt;/a&gt; collection.
You can set a default value to it, and this is where things get real easy. You can
bind the parameter to a control on your web form ( like a DropDownList)&amp;nbsp;, a Session
variable and even a query string parameter.&amp;nbsp; Adding&amp;nbsp; filtering functionality
is simple as that. You can do the same programmatically by adding Parameters to the
SelectParameters collection. Be sure to clear the collection before you add a parameter(
or check if the parameter exists).
&lt;/p&gt;
&lt;p&gt;
Paging is where working with the ODS gets a bit complicated. To enable paging ( in
conjunction with the GridView) set the EnablePaging property to true. The Employee
object too, needs to have methods to support paging. 
&lt;/p&gt;
&lt;p&gt;
When paging is enabled, the ODS calls the GetEmployee method with&amp;nbsp;two extra parameters.
by default the parameters are &lt;strong&gt;startRowIndex&lt;/strong&gt; and &lt;strong&gt;maximumRows&lt;/strong&gt;.
These can be changed by setting the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.startrowindexparametername.aspx"&gt;StartRowIndexParameterName&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.maximumrowsparametername.aspx"&gt;MaximumRowsParameterName&lt;/a&gt; properties.
&lt;/p&gt;
&lt;p&gt;
Now we need a GetEmployees method with the signature like&lt;br&gt;
GetEmployees(int startRowIndex,int maxiumRows)&lt;br&gt;
To support filtering it will have to be GetEmployees(string department ,int startRowIndex,int
maxiumRows)
&lt;/p&gt;
&lt;p&gt;
The maximumRows parameter, will have the value of how many rows to display per page.
This will have the value of the PageSize property of the GridView. The startRowIndex
will contain the the index of the current page. This can be the starting row index
of the current page of records. See &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx"&gt;here
for more on how to pass these on to an SQL query&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
In addition to this the ODS needs another method that is set by the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectcountmethod.aspx"&gt;SelectCountMethod&lt;/a&gt; property.
This is invoked to find out the total number of rows available. So we need another
static method in our Employee object. GetEmployeesCount() .If the total number of
rows is 100, and you have a page size of 20. The GetEmployees count method should
return 100, so that the ODS can tell the GridView, how many pager links to display.
I usually return this as an out parameter from the stored procedure that retrieves
the paged results.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Inserting, Editing and Deleting&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
Inserting, editing and deleting is pretty easy. All you will again is to have the
appropriate static methods in the Employee object.&lt;br&gt;
AddEmployee(Employee e)&lt;br&gt;
UpdateEmployee(Employee e)&lt;br&gt;
DeleteEmployee(Emplyee e).
&lt;/p&gt;
&lt;p&gt;
Set the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.insertmethod.aspx"&gt;InsertMethod&lt;/a&gt; , &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.updatemethod.aspx"&gt;UpdateMethod&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.deletemethod.aspx"&gt;DeleteMethod&lt;/a&gt; properties
accordingly. All these method can be configured with parameters like the SelectMethod.
However, setting the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.dataobjecttypename.aspx"&gt;DataObjectTypeName&lt;/a&gt; property
to the Employee object will reduce a lot of the hassle by passing Employee objects
to the Add,Update and DeleteMethods.
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,7dad8d70-ef72-4692-b0e5-59208d13912d.aspx</comments>
      <category>.Net Data</category>
      <category>.Net Web</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=f1dcc548-db37-422b-a25f-9695028fc335</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,f1dcc548-db37-422b-a25f-9695028fc335.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,f1dcc548-db37-422b-a25f-9695028fc335.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=f1dcc548-db37-422b-a25f-9695028fc335</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
While working with the System.Timers.Timer class last week, I found that the timer_elapsed
method is not synchronized, i.e the event is fired without waiting for the completion
of the previous invocation.
</p>
        <p>
Say for example you have a method that pulls up the latest records from a table and
do some processing. The timer event can fire while you are doing this processing and
have still not marked the records as processed. The safe way is to wrap the code in
the timer_elapsed event inside a lock statement.
</p>
      </body>
      <title>Timers and synchronization</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,f1dcc548-db37-422b-a25f-9695028fc335.aspx</guid>
      <link>http://www.hibri.net/2005/12/28/TimersAndSynchronization.aspx</link>
      <pubDate>Wed, 28 Dec 2005 22:36:32 GMT</pubDate>
      <description>
&lt;p&gt;
While working with the System.Timers.Timer class last week, I found that the timer_elapsed
method is not synchronized, i.e the event is fired without waiting for the completion
of the previous invocation.
&lt;/p&gt;
&lt;p&gt;
Say for example you have a method that pulls up the latest records from a table and
do some processing. The timer event can fire while you are doing this processing and
have still not marked the records as processed. The safe way is to wrap the code in
the timer_elapsed event inside a lock statement.
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,f1dcc548-db37-422b-a25f-9695028fc335.aspx</comments>
      <category>.Net Data</category>
      <category>.Net UI</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=9e727b7a-fa94-4bff-8b0e-cb492c8db9fd</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,9e727b7a-fa94-4bff-8b0e-cb492c8db9fd.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,9e727b7a-fa94-4bff-8b0e-cb492c8db9fd.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=9e727b7a-fa94-4bff-8b0e-cb492c8db9fd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The first step to migrate your SQL Server
</p>
        <p>
          <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=CF28DAF9-182E-4AC2-8E88-F2E936558BF2&amp;displaylang=en">Download
here</a>
        </p>
        <p>
"The Microsoft SQL Server 2005 Upgrade Advisor is a tool used by Database developers
and administrators to analyze SQL Server 7.0 and SQL Server 2000 database servers
in preparation for upgrading to SQL Server 2005. The Upgrade Advisor will allow users
to analyze the configuration of their existing database services and database applications.
As a result of this analysis, Upgrade Advisor will provide reports that identify deprecated
features and necessary configuration changes that will impact their Database upgrade
process. Upgrade Advisor will also provide links to documentation that describe these
changes and necessary steps to complete the process."
</p>
        <p>
 
</p>
      </body>
      <title>SQL Server 2005 Upgrade Advisor</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,9e727b7a-fa94-4bff-8b0e-cb492c8db9fd.aspx</guid>
      <link>http://www.hibri.net/2005/07/28/SQLServer2005UpgradeAdvisor.aspx</link>
      <pubDate>Thu, 28 Jul 2005 08:01:04 GMT</pubDate>
      <description>
&lt;p&gt;
The first step to migrate your SQL Server
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=CF28DAF9-182E-4AC2-8E88-F2E936558BF2&amp;amp;displaylang=en"&gt;Download
here&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
"The Microsoft SQL Server 2005 Upgrade Advisor is a tool used by Database developers
and administrators to analyze SQL Server 7.0 and SQL Server 2000 database servers
in preparation for upgrading to SQL Server 2005. The Upgrade Advisor will allow users
to analyze the configuration of their existing database services and database applications.
As a result of this analysis, Upgrade Advisor will provide reports that identify deprecated
features and necessary configuration changes that will impact their Database upgrade
process. Upgrade Advisor will also provide links to documentation that describe these
changes and necessary steps to complete the process."
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,9e727b7a-fa94-4bff-8b0e-cb492c8db9fd.aspx</comments>
      <category>.Net Data</category>
    </item>
    <item>
      <trackback:ping>http://www.hibri.net/Trackback.aspx?guid=7ab56c3a-539a-463e-8925-9cecd4cecd7a</trackback:ping>
      <pingback:server>http://www.hibri.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.hibri.net/PermaLink,guid,7ab56c3a-539a-463e-8925-9cecd4cecd7a.aspx</pingback:target>
      <dc:creator>Hibri</dc:creator>
      <wfw:comment>http://www.hibri.net/CommentView,guid,7ab56c3a-539a-463e-8925-9cecd4cecd7a.aspx</wfw:comment>
      <wfw:commentRss>http://www.hibri.net/SyndicationService.asmx/GetEntryCommentsRss?guid=7ab56c3a-539a-463e-8925-9cecd4cecd7a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.devx.com/dotnet/Article/27297">http://www.devx.com/dotnet/Article/27297</a>
        </p>
        <p>
Now if only they would release it !!.
</p>
        <p>
The release date has slipped to the end of this year. I wish they would just release
the runtime sooner or even backport some of the enhancements and bug fixes.
</p>
      </body>
      <title>Writing Provider-Independent Data Access Code with ADO.NET 2.0</title>
      <guid isPermaLink="false">http://www.hibri.net/PermaLink,guid,7ab56c3a-539a-463e-8925-9cecd4cecd7a.aspx</guid>
      <link>http://www.hibri.net/2005/03/22/WritingProviderIndependentDataAccessCodeWithADONET20.aspx</link>
      <pubDate>Tue, 22 Mar 2005 23:15:57 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.devx.com/dotnet/Article/27297"&gt;http://www.devx.com/dotnet/Article/27297&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Now if only they would release it !!.
&lt;/p&gt;
&lt;p&gt;
The release date has slipped to the end of this year. I wish they would just release
the runtime sooner or even backport some of the enhancements and bug fixes.
&lt;/p&gt;</description>
      <comments>http://www.hibri.net/CommentView,guid,7ab56c3a-539a-463e-8925-9cecd4cecd7a.aspx</comments>
      <category>.Net Data</category>
    </item>
  </channel>
</rss>