<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The long way back</title>
	<atom:link href="http://thelongwayback.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thelongwayback.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sat, 25 Jun 2011 04:54:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thelongwayback.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The long way back</title>
		<link>http://thelongwayback.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thelongwayback.wordpress.com/osd.xml" title="The long way back" />
	<atom:link rel='hub' href='http://thelongwayback.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Elmah &#8211; Not generatting XML Log File</title>
		<link>http://thelongwayback.wordpress.com/2011/06/25/elmah-not-generatting-xml-log-file/</link>
		<comments>http://thelongwayback.wordpress.com/2011/06/25/elmah-not-generatting-xml-log-file/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 04:54:02 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Error Logging / Handling]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=245</guid>
		<description><![CDATA[On adding Elmah to my web app (logging to XML files) I noticed that error logging worked fine on my development machine but when deployed to a server nothing was being logged. First thing I did was check that logging was working on the server by removing the errorLog setting in my web.config and trying [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=245&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On adding Elmah to my web app (logging to XML files) I noticed that error logging worked fine on my development machine but when deployed to a server nothing was being logged.</p>
<p>First thing I did was check that logging was working on the server by removing the errorLog setting in my web.config and trying it -<br />
<code></code></p>
<p>&lt;elmah&gt;<br />
&lt;security allowRemoteAccess=&#8221;yes&#8221; /&gt;<br />
<strong>&lt;errorLog type=&#8221;Elmah.XmlFileErrorLog, Elmah&#8221; logPath=&#8221;~/ErrorLogs&#8221; /&gt;</strong><br />
&lt;/elmah&gt;</p>
<p>Removed the line and logging (in memory) was working. OK so the problem has to be with creating the log file itself. Digging around provided some clues and suggestions about folder access.<br />
In the end I needed to give &#8216;Modify&#8217; permission on the &#8216;ErrorLogs&#8217; folder on the web server to the user account my site was running as. This could be the IIS user account. For me it was the account my App Pool was running as I had my site assigned to an Application Pool.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/245/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=245&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2011/06/25/elmah-not-generatting-xml-log-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>nhibernate &#8220;refers to an unmapped class: System.String&#8221;</title>
		<link>http://thelongwayback.wordpress.com/2011/06/06/nhibernate-refers-to-an-unmapped-class-system-string/</link>
		<comments>http://thelongwayback.wordpress.com/2011/06/06/nhibernate-refers-to-an-unmapped-class-system-string/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 15:02:52 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Nhibernate]]></category>
		<category><![CDATA[ORMs]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[Mapping]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=239</guid>
		<description><![CDATA[Came across this error today. It had me confused for a few minutes but it was an easy one to resolve and highlights a potential pitfall with copy/paste of entity maps. I&#8217;m mapping data from an external database into my main app&#8217;s repository. The external datasource has a composite key of 3 fields and these [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=239&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Came across this error today.  It had me confused for a few minutes but it was an easy one to resolve and highlights a potential pitfall with copy/paste of entity maps.<br />
I&#8217;m mapping data from an external database into my main app&#8217;s repository.</p>
<p>The external datasource has a composite key of 3 fields and these fields have names with suffixes of &#8216;id&#8217; but they&#8217;re strings not ints.  </p>
<p>My mapping file had something like<br />
<code><br />
    CompositeId()<br />
        .KeyReference(x =&gt; x.Mod_id)<br />
        .KeyReference(x =&gt; x.Year_id)<br />
        .KeyReference(x =&gt; x.Prog_id);</code></p>
<p>&#8216;KeyReference&#8217; was the issue.  As the fields / properties were strings I had to change them to &#8216;KeyProperty&#8217;.</p>
<p><code>    CompositeId()<br />
        .KeyProperty(x =&gt; x.Mod_id)<br />
        .KeyProperty(x =&gt; x.Year_id)<br />
        .KeyProperty(x =&gt; x.Prog_id);<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/239/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=239&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2011/06/06/nhibernate-refers-to-an-unmapped-class-system-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>Auditing with NHibernate &#8211; Event Listeners</title>
		<link>http://thelongwayback.wordpress.com/2010/12/01/auditing-with-nhibernate-event-listeners/</link>
		<comments>http://thelongwayback.wordpress.com/2010/12/01/auditing-with-nhibernate-event-listeners/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 11:54:43 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Auditing]]></category>
		<category><![CDATA[Nhibernate]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=235</guid>
		<description><![CDATA[I&#8217;ve been doing some work on an application which needed to implement auditing. I wanted to make it as un-obtrusive as possible, basically being able to switch the auditing on and let the system record changes made to entities. Used in conjunction with a generic respository, I&#8217;ve got something which is *almost* there. I&#8217;m fairly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=235&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some work on an application which needed to implement auditing.<br />
I wanted to make it as un-obtrusive as possible, basically being able to switch the auditing on and let the system record changes made to entities.  </p>
<p>Used in conjunction with a generic respository, I&#8217;ve got something which is *almost* there.  I&#8217;m fairly happy with what it&#8217;s doing and over the next few days I&#8217;m going to do a series of blog posts showing what I did and what I&#8217;m trying to do and I&#8217;d be grateful for any suggestions as I go.</p>
<p>I&#8217;ll start it from scratch and put the code in as I go.</p>
<p>If you&#8217;re reading this, it&#8217;s after 8th December and there&#8217;s still no content, drop a message here to give me a prod.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/235/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=235&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2010/12/01/auditing-with-nhibernate-event-listeners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>Fluent Nhibernate PersistenceSpecification : failed: System.ApplicationException   &#8211;  Expected List but got IList</title>
		<link>http://thelongwayback.wordpress.com/2010/09/09/fluent-nhibernate-persistencespecification-failed-system-applicationexception-expected-list-but-got-ilist/</link>
		<comments>http://thelongwayback.wordpress.com/2010/09/09/fluent-nhibernate-persistencespecification-failed-system-applicationexception-expected-list-but-got-ilist/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 16:35:52 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Nhibernate]]></category>
		<category><![CDATA[ORMs]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=227</guid>
		<description><![CDATA[This had me puzzled for a while this afternoon so I thought I&#8217;d put this post up. I was trying to get an integration test running, checking to see that an object was being persisted correctly (against an im-memory SQLite database). The test was failing with &#8220;failed: System.ApplicationException&#8221; Expected List&#60;&#62; but got IList&#60;&#62; The problem [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=227&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This had me puzzled for a while this afternoon so I thought I&#8217;d put this post up.</p>
<p>I was trying to get an integration test running, checking to see that an object was being persisted correctly (against an im-memory SQLite database).<br />
The test was failing with &#8220;failed: System.ApplicationException&#8221;  Expected List&lt;&gt; but got IList&lt;&gt;</p>
<p>The problem was with the type of check I was doing.   I was doing a property check but I should have been doing a &#8220;List&#8221; check.</p>
<p>Changing :</p>
<pre>              .CheckProperty(y =&gt; y.list, myList)</pre>
<p>To :</p>
<pre>             .CheckList(y =&gt; y.list, myList)</pre>
<p>Got it working.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=227&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2010/09/09/fluent-nhibernate-persistencespecification-failed-system-applicationexception-expected-list-but-got-ilist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>NHibernate : Could not insert &#8211; Blank Params &#8211; String or Binary data would be truncated.</title>
		<link>http://thelongwayback.wordpress.com/2010/08/26/nhibernate-could-not-insert-blank-params-string-or-binary-data-would-be-truncated/</link>
		<comments>http://thelongwayback.wordpress.com/2010/08/26/nhibernate-could-not-insert-blank-params-string-or-binary-data-would-be-truncated/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 09:41:58 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Nhibernate]]></category>
		<category><![CDATA[ORMs]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=225</guid>
		<description><![CDATA[I was using NHibernate when mapping some objects from a legacy system to objects in a new system and had an issue with one of the records failing to save. The error message was &#8220;String or binary data would be truncated. The statement has been terminated.&#8221; but when I looked at the SQL being executed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=225&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was using NHibernate when mapping some objects from a legacy system to objects in a new system and had an issue with one of the records failing to save.  </p>
<p>The error message was <em>&#8220;String or binary data would be truncated. The statement has been terminated.&#8221;</em>  but when I looked at the SQL being executed against the server the parameters were all question marks &#8211; <em>VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)</em>.</p>
<p>The error message was exactly right, the problem was caused by the truncation of data.  When I was mapping from my source object to my target object I was inserting a text string which was too long for the  property and when NHibernate was saving, the data was being truncated.   The question marks in the SQL output threw me though. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=225&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2010/08/26/nhibernate-could-not-insert-blank-params-string-or-binary-data-would-be-truncated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>Fluent NHibernate Object Referencing Instance of Itself / Self Referencing, Error &#8220;Repeated column in mapping for collection&#8221;</title>
		<link>http://thelongwayback.wordpress.com/2010/08/25/fluent-nhibernate-object-referencing-instance-of-itself-self-referencing/</link>
		<comments>http://thelongwayback.wordpress.com/2010/08/25/fluent-nhibernate-object-referencing-instance-of-itself-self-referencing/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 15:09:10 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Nhibernate]]></category>
		<category><![CDATA[ORMs]]></category>
		<category><![CDATA[NHibernate Error]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=216</guid>
		<description><![CDATA[I came across a problem with a Schema Fluent Nhibernate was generating for me yesterday.  I was getting the error message &#8220;Repeated column in mapping for collection&#8221;. I had an object, let&#8217;s call it &#8220;Item&#8221; which referenced instances of the same type, let&#8217;s call them &#8220;AssociatedItems&#8221;. Thinking of a simple real-life example, when you do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=216&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I came across a problem with a Schema Fluent Nhibernate was generating for me yesterday.  I was getting the error message <em>&#8220;<strong>Repeated column in mapping for collection&#8221;</strong></em>.</p>
<p>I had an object, let&#8217;s call it &#8220;Item&#8221; which referenced instances of the same type, let&#8217;s call them &#8220;AssociatedItems&#8221;.<br />
Thinking of a simple real-life example, when you do an oil change on your car you should change the oil filter and the sump-plug washer too.  So an oil filter Item would have associated items of oil and sump-plug washer.  Sump-plug washer would have associated items of oil and oil filter etc.</p>
<p>So the object looked something like this :</p>
<pre>public class Item
{
    public virtual int Id {get; set;}
    public virtual string Code {get; set;}
    public virtual string Description {get; set;}
    public virtual string IList&lt;Item&gt; AssociatedItems {get; set;}
}
</pre>
<p></p>
<p>Looks pretty straighforward.  Now to the Mapping : </p>
<pre>Public ItemMap()
{   
    Id(x =&gt; x.Id);
    Map(x =&gt; x.Code);
    Map(x =&gt; x.Description);
    HasManyToMany(x =&gt; x.AssociatedItems);
}</pre>
<p></p>
<p>OK, really simple.</p>
<p>Generating the schema, a table to handle the many-to-many relationships between Items and AssociatedItems is created.  It&#8217;s called something wierd like AssociatedItemsToAssociatedItems though and it only has one field / column called &#8220;Item_Id&#8221;.  I&#8217;m also getting an error message <em>&#8220;repeated column in mapping for collection &#8211; Item_Id&#8221;</em> &#8211; What&#8217;s going on?     The database generation seems to be getting confused because of the self reference / relationship and is trying to create a table with field name &#8220;Item_Id&#8221; for the parent object and &#8220;Item_Id&#8221; for the child object.</p>
<p>Getting around the problem was quite straightforward though and only involved a change to the mapping class.<br />
If you provide NHibernate with specific PK / FK names for the  relationships it will generate a table with two fields of the specificed names, a composite key  for the relationships.   Great!</p>
<pre>HasManyToMany(x =&gt; x.AssociatedItems)
     .ParentKeyColumn("Item_Id")   
     .ChildKeyColumn("AssociatedItem_Id")</pre>
<p></p>
<p>It still gives you a table with a crappy name though &#8211; bollocks!   What you need to do now though is tell NHibernate what it should call the table holding the relationship, explicitly define the name of the relationship table :</p>
<pre>    .Table("AssociatedItemToItem");</pre>
<p></p>
<p>So, the new, working map definition is :</p>
<pre>Public ItemMap()
{
   Id(x =&gt; x.Id);
   Map(x =&gt; x.Code);
   Map(x =&gt; x.Description);
   HasManyToMany(x =&gt; x.AssociatedItems)
        .ParentKeyColumn("Item_Id")
        .ChildKeyColumn("AssociatedItem_Id")
        .Table("AssociatedItemToItem");
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=216&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2010/08/25/fluent-nhibernate-object-referencing-instance-of-itself-self-referencing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>JQuery Data Annotations &#8211; Ignore MVC validators in Meta Data.</title>
		<link>http://thelongwayback.wordpress.com/2010/02/26/jquery-data-annotations-ignore-mvc-validators-in-meta-data/</link>
		<comments>http://thelongwayback.wordpress.com/2010/02/26/jquery-data-annotations-ignore-mvc-validators-in-meta-data/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 11:07:30 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[MVC2]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=200</guid>
		<description><![CDATA[I mentioned in a previous blog post that I was looking at jQuery Data Annotations.   This is really smart and provides more client-side attribute support out of the box than comes with MVC2.  It&#8217;s extendable so you can create your own attributes with corresponding validation. I found a slight glitch using JDA though.   I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=200&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I mentioned in a previous blog post that I was looking at <a title="jQuery Data Annotations" href="http://jda.codeplex.com/">jQuery Data Annotations</a>.   This is really smart and provides more client-side attribute support out of the box than comes with MVC2.  It&#8217;s extendable so you can create your own attributes with corresponding validation.</p>
<p>I found a slight glitch using JDA though.   I had encountered a problem where the meta data was applying the MVC required attribute for non-null types.  There&#8217;s a solution for this, <a title="blog post on MVR required attribute" href="http://thelongwayback.wordpress.com/2010/02/25/mvc2-rc-different-assemblies-addimplicitrequiredattributeforvaluetypes/">see my other post</a>.</p>
<p>I set this flag and sure enough the required attribute was dropped.  I did have another problem though, the MVC Numeric validator was automatically being applied to numeric types.   The ignore flag didn&#8217;t seem to have changed this behaviour.</p>
<p>In the end I took the JDA source code and made a small change.  Now it basically ignores any of the MVC validators returned from the meta data <strong>if</strong> the ignore flag has been set.  Original source code is available from the JDA site.  Changes are shown below in brown, wrapped so you can see them.</p>
<p>Modified source code for jQueryValidationExtension.cs :</p>
<pre>namespace System.Web.Mvc.Html
{
 using System;
 using System.ComponentModel; using System.Collections.Generic;
 using System.Data.Linq;
 using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Linq.Expressions;
 using System.Text;
 using System.Web.Mvc.Resources;
 using System.Web.Routing;
 using jQuery.Validation.DataAnnotations;

   public static class jQueryValidationExtensions
   {

     [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an appropriate nesting of generic types")]
     public static MvcHtmlString jQueryValidationFor&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression)
     {
         StringBuilder script = new StringBuilder();
         List&lt;string&gt; messages = new List&lt;string&gt;();
         List&lt;string&gt; validators = new List&lt;string&gt;();

         foreach (ModelValidator validator in ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).GetValidators(htmlHelper.ViewContext.Controller.ControllerContext))
         {
<span style="color:#ff6600;"><span style="color:#800000;">             if (validator.ShouldBeIgnored())
                 break;</span>
</span>             IEnumerable&lt;ModelClientValidationRule&gt; rules = validator.GetClientValidationRules();
             foreach (var a in rules)
             {
                 validators.Add(a.ValidationParameters["jQueryValidationInit"].ToString());
                 messages.Add(string.Format("{0}: \"{1}\"", a.ValidationParameters["jQueryName"].ToString(), a.ErrorMessage));                        
             }
         }

         foreach(Attribute valAttr in ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).ContainerType.GetCustomAttributes(true))
         {
             if(valAttr.GetType().Equals(typeof(EqualToAttribute)))
             {
                 EqualToAttribute attr = (EqualToAttribute)valAttr;
                 ModelMetadata.FromLambdaExpression(model =&gt; model, htmlHelper.ViewData);

                 EqualToValidator validator = new EqualToValidator(ModelMetadata.FromLambdaExpression(model =&gt; model, htmlHelper.ViewData), htmlHelper.ViewContext.Controller.ControllerContext, attr);
                 foreach (var a in validator.GetClientValidationRules())
                 {
                     if (ExpressionHelper.GetExpressionText(expression) == attr.SourceProperty)
                     {
                         validators.Add(a.ValidationParameters["jQueryValidationInit"].ToString());
                          messages.Add(string.Format("{0}: \"{1}\"", a.ValidationParameters["jQueryName"].ToString(), a.ErrorMessage));                            
                     }
                 }
             }
         }

         script.AppendFormat("$(\"#{0}\").rules(\"add\", {{", ExpressionHelper.GetExpressionText(expression));
         for (int i = 0; i &lt; validators.Count; i++)
         {
             script.AppendFormat("{0} ,", validators[i]);
         }

         script.Append("messages: {");
         for (int i = 0; i &lt; messages.Count; i++)
         {
             script.Append(messages[i]);
             if(i != messages.Count - 1)
             {
                 script.Append(",");
             }
         }

         script.Append("}});");
         return MvcHtmlString.Create(script.ToString());
     }

 <span style="color:#800000;">    private static bool MvcValidationIsSwitchedOff()
     {
         return (!DataAnnotationsModelValidatorProvider.
                    AddImplicitRequiredAttributeForValueTypes);
     }

     public static bool ShouldBeIgnored(this ModelValidator validator)
     {
         return (MvcValidationIsSwitchedOff() &amp;&amp;
                 validator.IsAnMvcValidator());            
     }

     public static bool IsAnMvcValidator(this ModelValidator validator)
     {
         return validator.GetType().BaseType.FullName.
                  Equals(typeof (ModelValidator).FullName);
     }</span>
  }
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=200&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2010/02/26/jquery-data-annotations-ignore-mvc-validators-in-meta-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>MVC2 RC &#8211; Different assemblies? AddImplicitRequiredAttributeForValueTypes</title>
		<link>http://thelongwayback.wordpress.com/2010/02/25/mvc2-rc-different-assemblies-addimplicitrequiredattributeforvaluetypes/</link>
		<comments>http://thelongwayback.wordpress.com/2010/02/25/mvc2-rc-different-assemblies-addimplicitrequiredattributeforvaluetypes/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:15:06 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[MVC2]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=192</guid>
		<description><![CDATA[I&#8217;ve been playing around with MVC2 looking to use it on a new project and was glad to see the release candidate was out.   Obviously if you&#8217;re looking to roll something out in the future you&#8217;re more confident using a RTM than a RC or a beta.  Beware though,MVC RC has been superseded by MVC2 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=192&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with MVC2 looking to use it on a new project and was glad to see the <a title="MVC Release Candidate" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=3B537C55-0948-4E6A-BF8C-AA1A78878DA0&amp;displaylang=en">release candidate was out</a>.   Obviously if you&#8217;re looking to roll something out in the future you&#8217;re more confident using a RTM than a RC or a beta.  Beware though,MVC RC has been superseded by <a title="MVC2 RC2" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7aba081a-19b9-44c4-a247-3882c8f749e3&amp;displaylang=en">MVC2 RC2</a> and now <a title="MVC2 RTM " href="http://weblogs.asp.net/scottgu/archive/2010/03/11/asp-net-mvc-2-released.aspx">MVC2 RTM</a>.   You&#8217;ll have to uninstall MVC2 RC / RC2 if you want to install the RTM.  If you&#8217;re using the VS2010 RC  be wary you don&#8217;t uninstall MVC2 &#8220;Visual Studio 2010 tools&#8221; when you&#8217;re uninstalling MVC2.  If you do, your new MVC2 projects probably won&#8217;t load.   If you do uninstall the 2010 tools you can re-install them by uninstalling the Wed Development part of VS2010 and then re-install it via add/remove program components (<a title="Phil Haacks Blog" href="http://haacked.com/archive/2010/02/10/installing-asp-net-mvc-2-rc-2-on-visual-studio.aspx">mentioned on Phil Haack&#8217;s blog</a>).</p>
<p>I&#8217;d been looking at Data Annotations and model validation and was really pleased to see how easy it was to get client-side validation up and running but the lack of supported attributes led me to look at <a title="JQuery Data Annotations" href="http://jda.codeplex.com/Thread/List.aspx">JQuery Data Annotations</a> as suggested by a colleague.</p>
<p>Again, great, this seemed to provide additional support.  I did encounter a problem though.   DataAnnotations was implementing a Required attribute on non-null data types automatically!!!!</p>
<p>Fortunately you can switch this behaviour off on the model validator provider.  The way to do this is to set the <em>AddImplicitRequiredAttributeForValueTypes </em>property to false.  I found this information on <a title="Jeremy Skinner's Blog Post" href="AddImplicitRequiredAttributeForValueTypes ">Jeremy Skinner&#8217;s blog post</a>.</p>
<p>OK&#8230;nearly there&#8230;.apart from the fact that <em>DataAnnotationsModelValidatorProvider</em> didn&#8217;t have an <em>AddImplicitRequiredAttributeForValueTypes </em>propery.<strong> </strong></p>
<p>Digging a bit more I found a post that suggested that there was <a title="Multiple MCV RCs" href="http://haacked.com/archive/2010/02/10/installing-asp-net-mvc-2-rc-2-on-visual-studio.aspx">more than one version of the MVC2 RC out there</a>.   I managed to get hold of another copy of System.Web.MVC from a colleague who had installed VS2010 RC.  He&#8217;d also installed MVC2 RC but wasn&#8217;t sure in which order.   The main thing was that it was different from the one in the MVC2 RC (as linked above).  It then became apparent that there was a new RC out there.</p>
<p>So&#8230;if you can&#8217;t set the <em>AddImplicitRequiredAttributeForValueTypes </em>propery because it doesn&#8217;t exist, check your dll version (System.Web.Mvc.dll).   2.0.41211.0 (356kb) was the version I originally had which came in the MVC2 RC download but this didn&#8217;t have the property.  2.0.50129.0 (365kb) did have the property, but this was in MVC2 RC2.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=192&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2010/02/25/mvc2-rc-different-assemblies-addimplicitrequiredattributeforvaluetypes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>IList ToArray Generic Extension Method &#8211; Summer of Nhibernate Session 6</title>
		<link>http://thelongwayback.wordpress.com/2009/12/09/ilist-toarray-generic-extension-method-summer-of-nhibernate-session-6/</link>
		<comments>http://thelongwayback.wordpress.com/2009/12/09/ilist-toarray-generic-extension-method-summer-of-nhibernate-session-6/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 16:35:24 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[Nhibernate]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=168</guid>
		<description><![CDATA[Still working through session 6 of the Summer of Nhibernate and got to the bit where Steve is creating a criteria expression.  He&#8217;s converting an IList&#60;int&#62; to an array of ints using a ToArray method. This conversion method doesn&#8217;t appear to be standard for IList and as I&#8217;m in a bit of a hurry today [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=168&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Still working through session 6 of the <a href="http://www.summerofnhibernate.com/">Summer of Nhibernate</a> and got to the bit where Steve is creating a criteria expression.  He&#8217;s converting an IList&lt;int&gt; to an array of ints using a ToArray method.<br />
This conversion method doesn&#8217;t appear to be standard for IList and as I&#8217;m in a bit of a hurry today I&#8217;ve assumed it&#8217;s an extension method and wrote my own (code below) so I can follow the screen cast:</p>
<pre><span style="color:#000080;">public static class MyExtensions
{
  public static T[] ToArray&lt;T&gt;(this IList&lt;T&gt; ListToConvert)
  {
    T[] arrayToReturn = new T[ListToConvert.Count];
    for (int i = 0; i &lt; arrayToReturn.Length; i++)
      arrayToReturn[i] = ListToConvert[i];
    return arrayToReturn;
  }
}</span></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=168&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2009/12/09/ilist-toarray-generic-extension-method-summer-of-nhibernate-session-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
		<item>
		<title>Nhibernate &#8211; c.Orders.elements is not mapped</title>
		<link>http://thelongwayback.wordpress.com/2009/12/07/nhibernate-c-orders-elements-is-not-mapped/</link>
		<comments>http://thelongwayback.wordpress.com/2009/12/07/nhibernate-c-orders-elements-is-not-mapped/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 14:51:26 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Nhibernate]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://thelongwayback.wordpress.com/?p=145</guid>
		<description><![CDATA[Problem  - HQL populating child collection without explicit join<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=145&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Continuing to Work through <a title="Summer of NHibernate" href="http://www.summerofnhibernate.com/">Steve Bohlen&#8217;s Summer of Nhibernate series</a> and encountered a problem with session 6&#8242;s HQL example of obtaining a collection of child objects from the database.</p>
<p>The HQL shown in the screen cast was :</p>
<pre><span style="color:#000080;">"select distinct c from Customer c , c.Orders.elements o where o.OrderDate &gt; :date"

</span></pre>
<p>Using this HQL gave me the following error :</p>
<pre><span style="color:#800000;">c.Orders.elements is not mapped

</span></pre>
<p>The syntax for obtaining the elements in the child collection has changed, and the correct syntax to be used is :</p>
<pre><span style="color:#000080;">elements(c.Orders)

</span></pre>
<p>This didn&#8217;t work for me either though (NHibernate 2.1.2.4000), I was getting the following error instead :</p>
<pre><span style="color:#800000;">Exception of type 'Antlr.Runtime.MissingTokenException'

</span></pre>
<p>I wasn&#8217;t getting very far with this problem, I couldn&#8217;t find a good example of HQL doing the same thing and I&#8217;m a bit anal in that I didn&#8217;t want to proceed with the rest of the screen cast while I had this up in the air.  In reality I doubt I&#8217;d ever use HQL but I still wanted to sort the problem.    In the end I&#8217;ve used the following HQL with an explicit inner join and fetch for the orders collection :</p>
<pre><span style="color:#000080;">"Select distinct c from Customer c inner join fetch c.Orders o
      where o.OrderDate &gt; :date"

</span></pre>
<p>This works great but I&#8217;m wondering if a shorter HQL statement will do the same thing as Steve demo&#8217;ed in his screen cast so I&#8217;m going to post a query on the <a title="http://groups.google.com/group/nhusers" href="http://">Nhibernate group</a>.   I&#8217;ll follow this post up once I&#8217;ve got a better solution.</p>
<p>** Update &#8211; 14th December 2009 **</p>
<p>I posted the query in the NHibernate user group and have received a response.   The problem was I wasn&#8217;t using the keyword &#8220;<span style="color:#000080;">as</span>&#8221; when giving the order collection an alias.   The hql to use is below :</p>
<pre>
<pre><span style="color:#000080;">"select distinct c from Customer c , elements(c.Orders) <span style="text-decoration:underline;"><span style="color:#0000ff;">as</span></span> o where o.OrderDate &gt; :date"</span></pre>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thelongwayback.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thelongwayback.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thelongwayback.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thelongwayback.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thelongwayback.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thelongwayback.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thelongwayback.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thelongwayback.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thelongwayback.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thelongwayback.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thelongwayback.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thelongwayback.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thelongwayback.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thelongwayback.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thelongwayback.wordpress.com&amp;blog=2753897&amp;post=145&amp;subd=thelongwayback&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thelongwayback.wordpress.com/2009/12/07/nhibernate-c-orders-elements-is-not-mapped/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/796a88d57feb294ba52085bf15a31f5b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rob</media:title>
		</media:content>
	</item>
	</channel>
</rss>
