<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Hangover &#187; .Net</title>
	<atom:link href="http://blog.codehangover.com/category/dot-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codehangover.com</link>
	<description>Go ahead, have another</description>
	<lastBuildDate>Sun, 15 Aug 2010 16:32:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>.Net Data Provider Overview</title>
		<link>http://blog.codehangover.com/net-data-provider-overview/</link>
		<comments>http://blog.codehangover.com/net-data-provider-overview/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 20:40:07 +0000</pubDate>
		<dc:creator>Welzie</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[data provider]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://blog.codehangover.com/?p=563</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://blog.codehangover.com/net-data-provider-overview/";</script>Summary
This is a high level summary of the basic .Net API’s for interacting with a database.  This includes a short description of each and how they relate to each other.  As a developer with mainly a Java and PHP background I was unclear about how ADO.Net related to OleDb and I had no [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://blog.codehangover.com/net-data-provider-overview/";</script><p><strong>Summary</strong><br />
This is a high level summary of the basic .Net API’s for interacting with a database.  This includes a short description of each and how they relate to each other.  As a developer with mainly a Java and PHP background I was unclear about how ADO.Net related to OleDb and I had no idea what was meant by the term “.Net Data Provider”.  I created this because the msdn documentation is HEAVILY focused on ADO.Net and does not give a clear picture of how the many namespaces, interfaces, and classes interact.  Please add comments to correct or enlighten.  Note at this time the relation of .Net Providers to Nhiberante, LINQ to SQL, and Entity Framework is not covered in this post.</p>
<p><strong>.Net Data Provider</strong></p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/a6cd7c08(v=VS.71).aspx">http://msdn.microsoft.com/en-us/library/a6cd7c08(v=VS.71).aspx</a></li>
<li>A .NET Framework data provider is used for connecting to a database, executing commands, and retrieving results. Those results are either processed directly, or placed in an ADO.NET DataSet.<br />
What that actually means is that a .Net Data Provider implements the interfaces defined in the System.Data namespace.</li>
<li>A .Net Data Provider is similar to a JDBC driver in Java</li>
<li><a href="http://en.wikipedia.org/wiki/Java_Database_Connectivit">http://en.wikipedia.org/wiki/Java_Database_Connectivity</a></li>
</ul>
<p><strong>System.Data</strong></p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/system.data.aspx">http://msdn.microsoft.com/en-us/library/system.data.aspx</a></li>
<li>This page contains text that makes you believe that ADO.Net is the CORE part of .Net data access, however the reality is that ADO.Net is the highest level of data access and is built upon the .Net Data Providers that implement the interfaces in the System.Data.
</li>
<li>
In my opinion it almost seems like microsoft is trying to hide how database connections work, so that users are trapped using controls provided by visual studio.</li>
<li>This namesapce contains the Interfaces that need to be defined by ALL .Net Data Providers</li>
<li>Core Interfaces
<ul>
<li>IDbConnection</li>
<li>IDbCommand</li>
<li>IDataAdapter</li>
<li>IDataReader</li>
</ul>
</li>
</ul>
<p><strong>Four examples of System.Data Implementations</strong></p>
<ul>
<li>The below namespaces include classes that implement the core “.Net Data Provider” interfaces defined in System.Data</li>
</ul>
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<p><strong>System.Data.SqlClient</strong>
</td>
<td>
<p><strong>System.Data.OleDb</strong>
</td>
<td>
<p><strong>System.Data.Odbc</strong>
</td>
<td>
<p><strong>IBM.Data.DB2.iSeries</strong>
</td>
</tr>
<tr>
<td>
<p><a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx"><br />
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx</a>
</td>
<td>
<p><a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.data.oledb.aspx">http://msdn.microsoft.com/en-us/library/system.data.oledb.aspx</a>
</td>
<td>
<p><a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.data.odbc.aspx">http://msdn.microsoft.com/en-us/library/system.data.odbc.aspx</a>
</td>
<td>
<p><a target="_blank" href="<br />
http://www-03.ibm.com/systems/i/software/access/windows/dotnet/index.html">http://www-03.ibm.com/systems/i/software/access/windows/dotnet/index.html</a>
</td>
</tr>
<tr>
<td>
<p><strong>Core Classes</strong></p>
<ul>
<li>SqlConnection</li>
<li>SqlCommand</li>
<li>SqlDataAdapter</li>
<li>SqlDataReader</li>
</ul>
</td>
<td>
<strong>Core Classes</strong></p>
<ul>
<li>OleDbConnection</li>
<li>OleDbCommand</li>
<li>OleDbDataAdapter</li>
<li>OleDbDataReader</li>
</ul>
</td>
<td>
<strong>Core Classes</strong></p>
<ul>
<li>OdbcConnection</li>
<li>OdbcCommand</li>
<li>OdbcDataAdapter</li>
<li>OdbcDataReader</li>
</ul>
</td>
<td>
<p><strong>Core Classes</strong></p>
<ul>
<li>iDB2Connection</li>
<li>iDB2Command</li>
<li>iDB2DataAdapter</li>
<li>iDB2DataReader</li>
</ul>
</td>
</tr>
</table>
<p><strong>ADO.Net</strong></p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/27y4ybxw(v=VS.71).aspx">http://msdn.microsoft.com/en-us/library/27y4ybxw(v=VS.71).aspx</a></li>
<li>ADO.Net is a database query and manipulation API built on top of the basic .Net Data Provider classes.  ADO.Net focuses on disconnected, multi-tier database interaction.  In my opinion the core ADO.Net classes should be in a separate namespace like System.Data.ADO just for the sake of clarity.</li>
<li>Core Classes
<ul>
<li>DataSet</li>
<li>DataTable</li>
<li>DataColumn</li>
<li>DataRelation</li>
</ul>
</li>
</ul>
<p><meta name="google-site-verification" content="Bq6Rop8-8fI5Z9VNovhl3nMfaY4Tlit0AxjXWZcFKwM" /></p>
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://blog.codehangover.com/php-framework-comparison/" title="PHP Framework Comparison">PHP Framework Comparison</a></li>
<li><a href="http://blog.codehangover.com/list-of-version-control-web-sites/" title="List of Version Control Web Sites">List of Version Control Web Sites</a></li>
<li><a href="http://blog.codehangover.com/asp-net-mvc-musings-and-book-review/" title="ASP.Net MVC Book Review and musings">ASP.Net MVC Book Review and musings</a></li>
</ul>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.codehangover.com%2Fnet-data-provider-overview%2F&amp;linkname=.Net%20Data%20Provider%20Overview"><img src="http://blog.codehangover.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.codehangover.com/net-data-provider-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NHibernate 2 Beginner&#8217;s Guide &#8211; Book Review</title>
		<link>http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/</link>
		<comments>http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 04:31:22 +0000</pubDate>
		<dc:creator>Welzie</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blog.codehangover.com/?p=542</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/";</script>Book on Amazon
Finally someone has written an in depth beginners book for nhibernate.  Nhibernate 2.0 Beginners Guide written by Aaron Cure is just that and more.  Wow do I sound like a car salesman.  I was a little disappointed when I read Nhibernate In Action last year, because it was more of a reference than [...]]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/";</script><p><a style="padding: 0 10px 10px 10px; float: right" href="http://www.amazon.com/gp/product/1847198902?ie=UTF8&amp;tag=1410softwarec-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1847198902"><img src="http://img101.imageshack.us/img101/9956/nhibernate2guide.jpg" border="0" alt="" /><br />
<span style="font-size: 8pt;">Book on Amazon</span></a></p>
<p>Finally someone has written an in depth beginners book for nhibernate.  Nhibernate 2.0 Beginners Guide written by Aaron Cure is just that and more.  Wow do I sound like a car salesman.  I was a little disappointed when I read <a id="rkhb" title="Nhiberate In Action" href="../nhibernate-in-action-book-review/" target="_blank">Nhibernate In Action</a> last year, because it was more of a reference than a tutorial.  This book is definitely what the title states, which is a beginners guide.  The book contains step by step examples of how to find, setup, and use nhibernate.  I highly recommend this book to anyone wanting to learn nhibernate.  By the way I think all .netters should do just that.</p>
<p><strong>Pros</strong></p>
<ul>
<li>love the beginning paragraphs
<ul>
<li>In simple terms, NHibernate does all the database work, and we reap all the benefits! Instead of writing reams of SQL statements or creating stored procedures that &#8220;live&#8221; in a different place than our code, we can have all of our data access logic contained within our application.<br />
With a few simple &#8220;tricks&#8221; that we&#8217;ll discuss in Chapter 4, Data Cartography, not only will our queries be effective, but they will also be validated by the compiler. Therefore, if our underlying table structure changes, the compiler will alert us that we need to change our queries!</li>
</ul>
</li>
<li>starts slow, which is perfect for a &#8220;beginners&#8221; book.  lots of hand holding and explanations of basics.  this is truly meant for somehow with no experience with <a id="l6an" title="ORMs" href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank"><span>ORMs</span></a>.</li>
<li>clearly shows you how to use log4net!  great bonus in a nhibernate book.</li>
<li>briefly mentions all the major players in the nhibernate world, which is great for demonstrating options
<ul>
<li>Examples: fluent nhibernate, nhibernate.burrow, castle, spring <span>ioc</span>, etc.</li>
</ul>
</li>
</ul>
<p><strong>Cons</strong></p>
<ul>
<li>book uses basic <span>aspx</span> pages with custom controls in the examples.  I firmly suggest ASP.Net MVC over <span>webforms</span>.  But it may be too much to learn at one time if you aren&#8217;t familiar with either <span>nhib</span> or MVC.  So learn one first and then learn the other.  You won&#8217;t regret it.</li>
<li>most examples are in c# and vb.net.  that&#8217;s good or bad depending on your opinion of vb.net.</li>
<li>No <a id="p5oq" title="HQL" href="http://nhforge.org/doc/nh/en/index.html#queryhql" target="_blank"><span>HQL</span></a> examples.  All query examples use the Criteria class.  This isn&#8217;t totally bad especially for beginners, but <span>HQL</span> should have at least been mentioned.</li>
</ul>
<p><strong>Chapter Notes</strong></p>
<ul>
<li>chapter 1
<ul>
<li>clearly denotes which version of <span>nhib</span> the book uses and where to get it
<ul>
<li>Even explains the <span>nhib</span> release verbiage of &#8220;generally available&#8221;</li>
</ul>
</li>
<li>shows basic examples of mapping file and how it relates to <span>POCOs</span>.  Good stuff for a <a id="b6sw" title="ORM" href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank">ORM</a> newbie.</li>
</ul>
</li>
<li>chapter 2
<ul>
<li>good advice for designing your database in logical way that avoids data duplication.</li>
<li>clear steps to download and setup a database using sql server express
<ul>
<li>Does mention that <span>nhib</span> works in almost any database, however all the book examples use sql server express</li>
</ul>
</li>
<li>nice explanation of how tables relate to your classes</li>
<li>great introduction to <span>OTM</span>, <span>MTO</span>, <span>MTM</span>, and <span>OTO</span> relationships</li>
<li>good summary of left joins and how joins matter in queries for the different relationship types</li>
</ul>
</li>
<li>chapter 3
<ul>
<li>starts creating a simple class library application.  clear steps and good examples.</li>
<li>even addresses the somewhat hated <span>nullable</span> types and how to handle database columns that need to be mapped to types that can be null.</li>
</ul>
</li>
<li>chapter 4
<ul>
<li>nice explanation of what mapping means in terms of <a id="t.5g" title="ORM" href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank">ORM</a> software and how it functions as the glue that binds your objects to the database.</li>
<li>summary and examples of the most common used mapping types</li>
<li>gives examples of two mapping styles
<ul>
<li>xml
<ul>
<li>lists the two main complaints which are.. 1) too much xml 2) xml files are not compiled, so you don&#8217;t find bugs until run time.</li>
<li>provides great tip of adding the hibernate <span>XSD</span> to  your project so that visual studio will provide code completion for you and validate your mapping files.</li>
<li>important info about how to make sure the xml mapping files are compiled into your <span>dll</span></li>
</ul>
</li>
<li>fluent nhibernate
<ul>
<li>short example given that shows how using the &#8220;side&#8221; project <a href="http://fluentnhibernate.org/" target="_blank">http://fluentnhibernate.org/</a> can work without the xml mapping files.</li>
<li>pro is that mappings have to be compiled, so bugs/typos are found earlier</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>chapter 5
<ul>
<li>creates console application to test the <span>nhib</span> code</li>
<li>shows step by step how to add references to the <span>nhib</span> <span>dlls</span> that you need to download</li>
<li>good definition of what a <span>nhib</span> session is and how it relates to an actual database session</li>
</ul>
</li>
<li>chapter 6
<ul>
<li>why you should and how to use log4net with your <span>nhib</span> project</li>
<li>excellent and thorough tutorial for using log4net</li>
</ul>
</li>
<li>chapter 7
<ul>
<li><span>nhib</span> config details</li>
<li>mentions how easy it is to change databases by simply changing one config line</li>
<li>shows how to config <span>nhib</span> in an app.config or web.config</li>
</ul>
</li>
<li>chapter 8
<ul>
<li>provides example of Singleton DOA pattern</li>
<li>shows example of using a structure that holds all the column/property names for a class/entity.  this is done so that the column names in the structure can be used in criteria queries.  all this effort is done to avoid run time exceptions.  seems like a waste of time to me because you if you don&#8217;t update your structure every time your db is updated then you will still get <span>runtime</span> errors.</li>
<li>query examples using Criteria (at this point all examples have been using Criteria, none in <span>HQL</span>)</li>
</ul>
</li>
<li>chapter 9
<ul>
<li>in depth examples showing how to create custom controls to display data retrieved using nhibernate</li>
</ul>
</li>
<li>chapter 10
<ul>
<li>shows how to implement the login controls with nhibernate</li>
</ul>
</li>
<li>chapter 11
<ul>
<li>covers 11 code generation tools used to limit manual boiler plate coding.  I actually hadn&#8217;t heard of many of the ones listed.  Great bonus chapter.</li>
<li><span>nhib</span>-gen, <span>mygeneration</span>, <span>NGen</span> NHibernate Code Generator, and T4 <span>hbm</span>2net seem promising</li>
<li>these tools create everything from <span>POCOs</span> to <span>DAOs</span> to services.</li>
</ul>
</li>
</ul>
<p><img class=" zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl zzvvvhvfecitsllxgenl" style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=1410softwarec-20&amp;l=as2&amp;o=1&amp;a=1847198902" border="0" alt="" width="1" height="1" /><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://blog.codehangover.com/nhibernate-in-action-book-review/" title="NHibernate in Action &#8211; Book Review">NHibernate in Action &#8211; Book Review</a></li>
<li><a href="http://blog.codehangover.com/outliers-a-non-technical-book-every-freelancerdeveloper-should-read/" title="Outliers &#8211; A non technical book every freelancer/developer should read">Outliers &#8211; A non technical book every freelancer/developer should read</a></li>
<li><a href="http://blog.codehangover.com/configuring-nhibernate-in-a-multiple-project-layout/" title="Configuring NHibernate in a Multiple Project Layout">Configuring NHibernate in a Multiple Project Layout</a></li>
</ul>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.codehangover.com%2Fbook-review-nhibernate-2-beginners-guide%2F&amp;linkname=NHibernate%202%20Beginner%26%238217%3Bs%20Guide%20%26%238211%3B%20Book%20Review"><img src="http://blog.codehangover.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NHibernate in Action &#8211; Book Review</title>
		<link>http://blog.codehangover.com/nhibernate-in-action-book-review/</link>
		<comments>http://blog.codehangover.com/nhibernate-in-action-book-review/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 16:35:48 +0000</pubDate>
		<dc:creator>Welzie</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blog.codehangover.com/?p=435</guid>
		<description><![CDATA[Review of the book "NHibernate In Action".  Pros &#038; cons along with suggestions for who this book would benefit.]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://blog.codehangover.com/nhibernate-in-action-book-review/";</script><p><a style="float: right" href="http://www.amazon.com/gp/product/1932394923?ie=UTF8&amp;tag=1410softwarec-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1932394923"><img src="http://img94.imageshack.us/img94/9959/nhibernateinaction.jpg" border="0" alt="" /><span style="font-size: small;"><br />
<span style="font-size: 8pt;">Book on Amazon</span></span></a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=1410softwarec-20&amp;l=as2&amp;o=1&amp;a=1932394923" border="0" alt="" width="1" height="1" /><br />
All summer I meant to read the book &#8220;NHibernate In Action&#8221;.  I finally got around to it, better late than never I guess. In my opinion this book is aimed at higher level programmers such as lead developers or architects.  The book does not contain clear step by step examples of how to get NHibernate running.  However it does provide in depth conceptual reasoning why anyone would want to use NHibernate along with reference style examples.  If you are trying to learn NHibernate  you are better off reading a few online tutorials first and after that read this book so you can understand exactly what NHibernate is doing and how it does it.  Below are some book pros &amp; cons, NHibernate links, and chapter summaries.</p>
<h4>Pros</h4>
<ul>
<li> Examples are all in c#</li>
<li> Shows config examples for NHibernate 1.2.1 and 2</li>
<li> Promotes proper design patters often references popular pattern books</li>
<li> Makes note of minor current bugs or missing features that may cause issues or confusion</li>
<li> Provides suggestions for when to use something other than the default NHibernate settings</li>
<li> Mentions how NHibernate can use the features of multiple RDMS, not just SQL Server</li>
</ul>
<h4>Cons</h4>
<ul>
<li> Download and install instructions were vague
<ul>
<li> I downloaded <a href="http://sourceforge.net/projects/nhibernate/files/">NHibernate 2.1.0 QA from SourceForge</a> after finally finding the link on nhforge.org.  From there I followed the install notes in the downloaded zip file.</li>
</ul>
</li>
<li> Examples do not use Generics</li>
<li> Doesn&#8217;t provide a link or even a suggestion to where you can download the NHibernate.Mapping.Attributes library which lets you use features similar to the annotations in Hibernate 3
<ul>
<li>I found them here: http://sourceforge.net/projects/nhcontrib/files/NHibernate.Mapping.Attributes/</li>
</ul>
</li>
<li> Shows attribute and xml mapping examples randomly.  In my opinion it would be better if one or the other was used consistently.</li>
<li> Jumps from definitions to examples. No clear step by step examples
<ul>
<li>I would say this book is more of a reference than tutorial</li>
</ul>
</li>
</ul>
<h4>Helpful NHibernate Links</h4>
<ul>
<li><a href="http://nhforge.org">NHibernate community site</a>
<ul>
<li>Great <a href="http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx">short tutorial</a></li>
<li><a href="http://nhforge.org/doc/nh/en/index.html">NHibernate docs</a></li>
</ul>
</li>
<li><a href="http://groups.google.com/group/nhusers/">NHibernate Google Group</a></li>
<li><a href="http://stackoverflow.com/questions/tagged/nhibernate">Stackoverflow NHibernate</a> questions and answers</li>
<li>How to use <a href="http://iseesharp.blogspot.com/2006/09/connecting-mysql-and-c.html">MySQL with .NET</a></li>
<li><a href="https://www.hibernate.org/361.html">Databases supported</a> by NHibernate</li>
<li><a href="http://swik.net/tag4sree/Hibernate+-+Objects/Common+nHibernate+exceptions+and+a+question/b4013">Common exceptions </a></li>
</ul>
<h4>Chapter 1</h4>
<ul>
<li> Basic definitions of persistence, sql(sql not sql server) databases, and layered development</li>
<li>Doesn&#8217;t mention the testability benefits of layered development</li>
<li> Compares persistence layer choices available with .Net</li>
<li> Makes the case that LINQ and Entity framework will not replace NHibernate</li>
<li> Definition of ORM</li>
<li> Addresses the performance concerns of using ORMs</li>
<li> Author tries to convince people to use ORMs, this part needs a little salesman ship but I guess if someone is open minded enough to read this book then they don&#8217;t need much of a sales pitch.</li>
</ul>
<h4>Chapter 2</h4>
<ul>
<li> Some basoc instructions for how to download and install the NHibernate dll
<ul>
<li>con: Could use a little details in this section about how to use the versions that don&#8217;t have msi installers yet like the 2.1.0.GA release I downloaded.</li>
</ul>
</li>
<li> Shows very simple examples of saving and loading an entity</li>
<li> Then shows you a basic xml mapping document
<ul>
<li>o Shows a mapping document for versions 1.2 and 2.</li>
</ul>
</li>
<li> Quick glance at the NHibernate api and in depth notes on important interfaces</li>
<li> Very short section on logging with log4net</li>
</ul>
<h4>Chapter 3</h4>
<ul>
<li> Good section on the benefits of having a transparent persistence layer</li>
<li> Discusses the anti xml config file movement.
<ul>
<li>However doesn&#8217;t mention the fact that poorly designed and overly complicated schemas are one reason for the back lash.  Also never mentions CoC.</li>
</ul>
</li>
<li> Discusses using attributes as meta data
<ul>
<li>IMHO way more time should have been spent telling the users how to setup/install the mapping dlls needed to use this feature</li>
<li>Does show many examples of how to use the attributes and what the xml version of the meta data would look like</li>
</ul>
</li>
<li> This chapter provides information about the hibernate mapping elements and options
<ul>
<li>It is a mix between a reference and tutorial.</li>
</ul>
</li>
<li> Good section on object identity vs equality</li>
<li> con:  Gives an explanation of what primary keys are.  Surely anyone reading this book knows already knows what primary keys are.</li>
<li> Good short explanation of the different types of primary key creation that NHibernate supports</li>
<li> Long discussion on database and object model design
<ul>
<li>table per concrete class</li>
<li>table per sub class</li>
<li>table per class hierarchy</li>
</ul>
</li>
</ul>
<h4>Chapter 4</h4>
<ul>
<li> Explains object identity scope.  probably a little high level for low level developers</li>
<li> Explains different options for Equals and HashCode implementations</li>
<li> Automatic dirty checking
<ul>
<li>Changing an object in an ISession and committing will result in those changes being automatically reflected in the database</li>
</ul>
</li>
<li> Clearly denotes the different cascading persistence options</li>
<li> Details the different object retrieval options
<ul>
<li>Retrieving by identifier</li>
<li>HQL</li>
<li>NHibernate Criteria API</li>
<li>Native SQL queries</li>
</ul>
</li>
<li> In depth discussion of fetching strategies and how to implement each one</li>
<li> Short section on batching and how it can speed up queries for selecting collections</li>
<li> Provides common sense ideas for analyzing NHibernate&#8217;s performance</li>
</ul>
<h4>Chapter 5</h4>
<ul>
<li> Background on database transactions, unit of work and conversations</li>
<li> Excellent section on transaction isolation</li>
<li> Background on ORM caching</li>
</ul>
<h4>Chapter 6</h4>
<ul>
<li> Starts with more definitions and comparisons of entities and value types</li>
<li> Nice chart showing how NHibernate mapping types relate to .Net types</li>
<li> Give in depth example of creating a custom mapping type</li>
<li> Nice tips on controlling collection sorting with mapping settings</li>
</ul>
<p><a href="http://www.amazon.com/gp/product/1932394923?ie=UTF8&amp;tag=1410softwarec-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1932394923"><img src="http://img94.imageshack.us/img94/9959/nhibernateinaction.jpg" border="0" alt="" width="50" height="75px" /><br />
</a><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/" title="NHibernate 2 Beginner&#8217;s Guide &#8211; Book Review">NHibernate 2 Beginner&#8217;s Guide &#8211; Book Review</a></li>
<li><a href="http://blog.codehangover.com/configuring-nhibernate-in-a-multiple-project-layout/" title="Configuring NHibernate in a Multiple Project Layout">Configuring NHibernate in a Multiple Project Layout</a></li>
<li><a href="http://blog.codehangover.com/asp-net-mvc-musings-and-book-review/" title="ASP.Net MVC Book Review and musings">ASP.Net MVC Book Review and musings</a></li>
</ul>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.codehangover.com%2Fnhibernate-in-action-book-review%2F&amp;linkname=NHibernate%20in%20Action%20%26%238211%3B%20Book%20Review"><img src="http://blog.codehangover.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.codehangover.com/nhibernate-in-action-book-review/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Configuring NHibernate in a Multiple Project Layout</title>
		<link>http://blog.codehangover.com/configuring-nhibernate-in-a-multiple-project-layout/</link>
		<comments>http://blog.codehangover.com/configuring-nhibernate-in-a-multiple-project-layout/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 03:58:53 +0000</pubDate>
		<dc:creator>Welzie</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://blog.codehangover.com/?p=417</guid>
		<description><![CDATA[I recently had to setup NHibernate in a multiple project c#, asp.net MVC solution. Since most of the tutorials and books only show a basic single project layout I thought I would post an example of how to configure NHiberate with a multi-project solution.]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://blog.codehangover.com/configuring-nhibernate-in-a-multiple-project-layout/";</script><p>I recently had to setup NHibernate in a multiple project c#, asp.net MVC solution.  Since most of the tutorials and books only show a basic single project layout I thought I would post an example of how to configure NHiberate with a multi-project solution.</p>
<p>The main problem I had was that my model objects or entity objects were in a separate project than my database access code which contained the .hbm.xml mapping files.  When I tried to configure NHibernate with the basic examples I was getting an &#8220;NHibernate.MappingException : No persister for: YourClass&#8221; exception.  I was still getting that exception even after changing the .hbm.xml files to be an &#8220;Embedded Resource&#8221;.  I finally figured out that my .hbm.xml files needed to reference the ModelLayer assebmly and my NHibernate.Cfg.Configuration.AddAssembly() needed to reference the DataAccessLayer assebmly.  See screen shots and code examples below for more details.</p>
<h4>Solution layout</h4>
<div style="float: left;">
<ul>
<li>DataAccessLayer</li>
</ul>
<ul>
<ul>
<li>Duh. Database code</li>
<ul>
<li>References</li>
<ul>
<li>ModelLayer</li>
</ul>
</ul>
</ul>
<li>ModelLayer</li>
<ul>
<li>Model objects</li>
</ul>
<li>MvcAgain (web layer)</li>
<ul>
<li>ASP.Net project</li>
<li>References</li>
<ul>
<li>ModelLayer</li>
<li>ServiceLayer</li>
</ul>
</ul>
<li>ServiceLayer</li>
<ul>
<li>Business logic</li>
<li>Reusable logic</li>
<li>References</li>
<ul>
<li>ModelLayer</li>
<li>DataAccessLayer</li>
</ul>
</ul>
</ul>
</div>
<div style="float: right;">
<img src="http://img15.imageshack.us/img15/3041/projlayout.gif"/>
</div>
<div style="clear: both; padding-bottom: 10px;"></div>
<h4>Model objects Car.cs and CarLot.cs</h4>
<pre class="brush: java;">
using System.ComponentModel.DataAnnotations;
namespace MvcAgain.Models {
    public class Car {
        [Required]
        public virtual int Id {get; set;}
        [StringLength(35), Required]
        public virtual string Manufacturer {get; set;}
        [StringLength(35), Required]
        public virtual string Model {get; set;}
        public virtual CarLot Lot {get; set;}
    }
}//end of Car.cs

using Iesi.Collections;
using System.ComponentModel.DataAnnotations;
namespace MvcAgain.Models {
    public class CarLot {
        [Required]
        public virtual int Id { get; protected set; }
        [StringLength(35), Required]
        public virtual string Name { get; protected set; }
        public virtual ISet Cars { get; protected set; }
    }
}//end of CarLot.cs
</pre>
<p><br/></p>
<h4>Car.hbm.xml and CarLot.hbm.xml</h4>
<p>These .hbm.xml files are in the DataAccessLayer project, but they reference the ModelLayer assembly.</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;hibernate-mapping xmlns=&quot;urn:nhibernate-mapping-2.2&quot;
                   assembly=&quot;ModelLayer&quot;
                   namespace=&quot;MvcAgain.Models&quot;&gt;
  &lt;class name=&quot;MvcAgain.Models.Car&quot; lazy=&quot;false&quot; table=&quot;cars&quot;&gt;
    &lt;id name=&quot;Id&quot;&gt;
      &lt;generator class=&quot;native&quot;/&gt;
    &lt;/id&gt;
    &lt;property name=&quot;Model&quot;/&gt;
    &lt;property name=&quot;Manufacturer&quot;/&gt;
    &lt;many-to-one name=&quot;Lot&quot; class=&quot;CarLot&quot; column=&quot;lotid&quot; not-null=&quot;true&quot;&gt;
    &lt;/many-to-one&gt;
  &lt;/class&gt;
&lt;/hibernate-mapping&gt;

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;hibernate-mapping xmlns=&quot;urn:nhibernate-mapping-2.2&quot;
                   assembly=&quot;ModelLayer&quot;
                   namespace=&quot;MvcAgain.Models&quot;&gt;
  &lt;class name=&quot;MvcAgain.Models.CarLot&quot; lazy=&quot;false&quot; table=&quot;carlots&quot;&gt;
    &lt;id name=&quot;Id&quot;&gt;
      &lt;generator class=&quot;native&quot;/&gt;
    &lt;/id&gt;
    &lt;property name=&quot;Name&quot;/&gt;
    &lt;set name=&quot;Cars&quot; inverse=&quot;true&quot;&gt;
        &lt;key column=&quot;lotid&quot;/&gt;
        &lt;one-to-many class=&quot;Car&quot;/&gt;
    &lt;/set&gt;
  &lt;/class&gt;
&lt;/hibernate-mapping&gt;
</pre>
<p><br/></p>
<h4>NHibernateSessionFactory.cs (NHibernate configuration code)</h4>
<pre class="brush: java;">
using NHibernate.Cfg;
using NHibernate;
namespace MvcAgain.DataAccessLayer {

    public class NHibernateSessionFactory {

        private static ISessionFactory sessionFactory = null;

        private static ISessionFactory SessionFactory {
            get {
                if(sessionFactory == null) {
                    Configuration configuration = new Configuration();
                    configuration.Configure();
                    //note: you must use the name of the assembly
                    //that contains the .hbm.xml mapping files.
                    //For this example NHibernate will load all .hbm.xml files it
                    //finds in the DataAccessLayer assembly
                    configuration.AddAssembly(&quot;DataAccessLayer&quot;);
                    sessionFactory = configuration.BuildSessionFactory();
                }
                return sessionFactory;
            }
        }

        public static ISession OpenSession() {
            return SessionFactory.OpenSession();
        }
    }//end of class
}//end of namespace
</pre>
<p></br></p>
<h4>ModelLayer assembly name in the properties pane.</h4>
<p><img src="http://img40.imageshack.us/img40/7961/assemblyname.gif"/><br />
<br/><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://blog.codehangover.com/nhibernate-in-action-book-review/" title="NHibernate in Action &#8211; Book Review">NHibernate in Action &#8211; Book Review</a></li>
<li><a href="http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/" title="NHibernate 2 Beginner&#8217;s Guide &#8211; Book Review">NHibernate 2 Beginner&#8217;s Guide &#8211; Book Review</a></li>
<li><a href="http://blog.codehangover.com/asp-net-mvc-musings-and-book-review/" title="ASP.Net MVC Book Review and musings">ASP.Net MVC Book Review and musings</a></li>
</ul>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.codehangover.com%2Fconfiguring-nhibernate-in-a-multiple-project-layout%2F&amp;linkname=Configuring%20NHibernate%20in%20a%20Multiple%20Project%20Layout"><img src="http://blog.codehangover.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.codehangover.com/configuring-nhibernate-in-a-multiple-project-layout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.Net MVC Book Review and musings</title>
		<link>http://blog.codehangover.com/asp-net-mvc-musings-and-book-review/</link>
		<comments>http://blog.codehangover.com/asp-net-mvc-musings-and-book-review/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 05:27:04 +0000</pubDate>
		<dc:creator>Welzie</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://blog.codehangover.com/?p=307</guid>
		<description><![CDATA[My thoughts on ASP.Net MVC followed by a review of the Apress book Pro ASP.NET MVC Framework by Steve Sanderson.]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://blog.codehangover.com/asp-net-mvc-musings-and-book-review/";</script><h2><strong>ASP.Net MVC musings</strong></h2>
<ul>
<li>ASP.Net MVC is a <a href="http://en.wikipedia.org/wiki/Convention_over_configuration">CoC</a> <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">MVC</a> framework, it&#8217;s not a &#8220;full stack&#8221; framework.  You still need to implement some type of database layer.</li>
<li>Traditional ASP.net web forms attempts to hide the core parts of web development HTML, JS, CSS.  ASP.Net MVC does not.</li>
<li>Learning a pattern like MVC in web framework that allows developers to be aware of HTML, JS, CSS will only benefit you as a web developer.
<ul>
<li>If you actually understand how web pages work it makes you a better debugger and a more well rounded programmer.   You are able to more easily apply your knowledge and skill set to other languages/platforms.  I know that some web form developers do know the details of web development, but in my opinion most do not.</li>
</ul>
</li>
<li>The fact that ASP.Net MVC makes it easier to test will not appeal to people who have never written a unit test in their life.  You have to convince such people by showing a real world example demonstrating how test coverage can save you loads of time and money in the maintenance phase of application development.  But at that point you will only get architects and project managers to buy in, the lazy developers that fear learning anything new will still avoid ASP.Net MVC like the swine flu.</li>
<li>The fact that the MVC pattern is a common pattern among other web development environments such as Java and PHP will also not appeal to most Microsoft developers.  However the really smart ones will realize that more common knowledge will only help if you ever have to do any type of development other than microsoft development</li>
</ul>
<h2><strong>Book Review &#8211; <a href="http://www.amazon.com/gp/product/1430210079?ie=UTF8&amp;tag=1410softwarec-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1430210079">Pro ASP.Net MVC Framework &#8211; Steven Sanderson</a></strong></h2>
<p style="text-align: left;"><a style="float: right" href="http://www.amazon.com/gp/product/1430210079?ie=UTF8&amp;tag=1410softwarec-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1430210079"><img src="http://img10.imageshack.us/img10/8153/proaspmvcu.jpg" border="0" alt="" /><br/><span style="font-size: 8pt;">Book on Amazon</span></a> I am a Java, PHP, and .Net developer which may make my opinion worthless to some Microsoft zealots but I thought I would type up my thoughts on this book anyway.  Overall I found this book to be a great way to learn ASP.Net MVC.  It has great examples and enough background material to bring people new to the MVC pattern up to speed.  Below are my pros and cons along with notes on chapters 1-13.</p>
<h4>Note about the cover.</h4>
<p>One thing I found interesting is that the cover says &#8220;Discover the biggest innovation in Microsoft web development since asp.net 1.0&#8243;.  I find it amusing that something as old as MVC web frameworks can be called an innovation for asp.net development since MVC frameworks are nothing new to web development.  Heck they are not even new to ASP.Net development.  See <a href="http://www.castleproject.org/monorail/">MonoRail</a> .</p>
<h4>Pros</h4>
<ul>
<li>Provides good definition of MVC and explains why you want to use it</li>
<li>Overall all the examples are clear and concise</li>
<li>Gives examples of how to test every part of ASP.Net MVC</li>
<li>Moves quick enough for someone with MVC experience and slow enough for someone with no MVC experience</li>
<li>Great chapter on web site security</li>
<li>Book often demonstrates C# 3 language features</li>
</ul>
<h4>Cons</h4>
<ul>
<li>Database examples use <a href="http://en.wikipedia.org/wiki/Linq#LINQ_to_SQL" target="_blank">LINQ to SQL</a>.
<ul>
<li>
As many have noted this isn&#8217;t a major con. It was probably used to keep the examples shorter.  Whether you like LINQ to SQL or not that is a good thing.
 </li>
</ul>
</li>
<li>No mention of Mono project or any hints of how to get ASP.Net working with Mono.</li>
<li>Book examples are for the &#8220;real&#8221; version of VS2008 not the free VWDE2008.</li>
<li>Does not provide a good example of using a validation utility such as XVal or Data Annotations</li>
</ul>
<h4>Chapter 1</h4>
<ul>
<li>An adequate history lesson for those unfamiliar with MVC.</li>
</ul>
<h4>Chapter 2</h4>
<ul>
<li>A great chapter that quickly and easily shows you the basics of ASP.Net MVC</li>
</ul>
<h4>Chapter 3</h4>
<div>
<ul>
<li>Gives in depth definition to each part of MVC</li>
<li>Gives good definition of entities <em>vs</em> value objects</li>
<li>Lists design and pattern best practices</li>
<li>Brief discussion of IoC and IoC containers</li>
<li>Brief discussion on automated testing and the TDD movement</li>
<li>Gives example of creating mock implementations for testing</li>
</ul>
<h4>Chapter 4</h4>
<ul>
<li>Goes into medium depth while building a project with unit testing, domain model, and web layer</li>
<li>uses LING to SQL for database interactions</li>
<li>Sets up IoC with Castle Windsor</li>
<li>Shows how to use Nunit and Moq to create unit tests</li>
<li>Good definition of TDD and how the author thinks of it as actually BDD (behaviour driven development)</li>
</ul>
<h4>Chapter 5</h4>
</div>
<div>
<ul>
<li>Examples of how to test every part of ASP.Net MVC</li>
<li>Shows example of how to only expose an interface in your controller to avoid tying the controller to your business logic implementation</li>
</ul>
<h4>Chapter 6</h4>
<ul>
<li>CRuD actions and views are added to the example project</li>
<li>Example of username/password authentication</li>
<li>Shows how to upload an image through a form field</li>
</ul>
<h4>Chapter 7</h4>
<ul>
<li>Detail of asp.net MVC project folder structure
<ul>
<li>Very well done, explains the what/why for each folder</li>
</ul>
</li>
<li>Goes over the naming convention which are  crucial since ASP.Net MVC follows CoC</li>
</ul>
<h4>Chapter 8</h4>
<ul>
<li>Everything you need to know about how url routing works and also how to create links in your application to your controllers/actions</li>
</ul>
<h4>Chapter 9</h4>
<ul>
<li>More details on what code belongs in a controller/action</li>
<li>More details on how the views are rendered</li>
<li>Example of how to use the [Authorize] filter attribute, which is a great way to easily secure your actions individually</li>
</ul>
<h4>Chapter 10</h4>
</div>
<div>
<ul>
<li>Details on how views work specifically how data is passed between layers and tools available to display that data.  Specifically the HTML helpers.</li>
</ul>
<h4>Chapter 11</h4>
<ul>
<li>Everything you need to know about how to modify and configure how data is retrieved from forms and urls and then binded to action parameters and model objects</li>
<li>Validation
<ul>
<li>Author basically suggest using plain c# in the model layer for validation.  doesn&#8217;t list the re-usability and &#8220;all ready done for YOu&#8221; benefits of using a validation utility.</li>
</ul>
</li>
</ul>
<h4>Chapter 12</h4>
<ul>
<li>Simple examples of how to use the AJAX HTML helpers which includes JQuery.</li>
</ul>
<h4>Chapter 13</h4>
<ul>
<li>Demonstrates basics of HTTP requests to help you understand how vulnerable web sites are.  Really good reading for less experienced web developers.
<ul>
<li>Gives example of how to fake an http request</li>
<li>Gives examples of using tools like firebug and fiddler</li>
<li>Details cross-site scripting and html injection</li>
<li>Details how one of the previous chapter examples had a vulnerability and how it can be fixed</li>
</ul>
</li>
</ul>
</div>
<p><a href="http://www.amazon.com/gp/product/1430210079?ie=UTF8&amp;tag=1410softwarec-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1430210079"><img width="55px" height="70px" src="http://img132.imageshack.us/img132/7254/51accymgtlsl110.jpg" border="0" alt="" /><br/><span style="font-size: 8pt;">Book on Amazon</span></a><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://blog.codehangover.com/nhibernate-in-action-book-review/" title="NHibernate in Action &#8211; Book Review">NHibernate in Action &#8211; Book Review</a></li>
<li><a href="http://blog.codehangover.com/spring-patterns-best-practices-and-design-strategies-book-review/" title="Spring Patterns: Best Practices and Design Strategies Book Review">Spring Patterns: Best Practices and Design Strategies Book Review</a></li>
<li><a href="http://blog.codehangover.com/book-review-nhibernate-2-beginners-guide/" title="NHibernate 2 Beginner&#8217;s Guide &#8211; Book Review">NHibernate 2 Beginner&#8217;s Guide &#8211; Book Review</a></li>
</ul>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.codehangover.com%2Fasp-net-mvc-musings-and-book-review%2F&amp;linkname=ASP.Net%20MVC%20Book%20Review%20and%20musings"><img src="http://blog.codehangover.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.codehangover.com/asp-net-mvc-musings-and-book-review/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
