<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>PrimordialCode</title><link>http://www.primordialcode.com/</link><description>Where Mammoths runs wild on your mind!</description><copyright>Giorgetti Alessandro</copyright><docs>http://www.rssboard.org/rss-specification</docs><generator>http://dexterblogengine.codeplex.com</generator><language>en-GB</language><lastBuildDate>Tue, 07 Feb 2012 09:15:34 GMT</lastBuildDate><webMaster>Guardian</webMaster><category>.Net NHibernate Wpf Silverlight Windows Phone</category><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/PrimordialCode" /><feedburner:info uri="primordialcode" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by/3.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2FPrimordialCode" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item><title>Configure WebMatrix/IIS Express to work with WP7 on Windows 7</title><description>&lt;p&gt;Long time is passed after my last ‘notable’ blog post, I was just too busy and lazy in the past months, lots of things happened and I couldn’t follow everything, but it’s not that I want to talk about, let’s talk about some more WP7 development.&lt;/p&gt;  &lt;p&gt;Actually I am ‘playing’ with WP7, jQuery Mobile, WCF services and some various mobile stuff these days, honestly I was tired of having my WP7 device connected to the USB cable in order to be able to surf websites and use services that are hosted on my development machine. So I started to scouting around looking for a solution.&lt;/p&gt;  &lt;p&gt;My goal is to be able to host websites and WCF services using WebMatrix ad IIS Express at first and a custom made WCF self hosting solution at a later time for my developing everyday life (and for demo purposes).&lt;/p&gt;  &lt;p&gt;So here’s my current setup:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;IIS Express/WebMatrix &lt;/li&gt;    &lt;li&gt;Zune &lt;/li&gt;    &lt;li&gt;WP7 + USB cable connected &lt;/li&gt;    &lt;li&gt;a fantastic website hosted on IIS Express &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Everything is working correctly here, I can browse the website from WP7 and test it, but I have to keep the cable connected, which is a no go if I want to make a demo of something to someone with a ‘floating’ device. I do not want to create new DNS entries, nor touch the network infrastructure nor do any other complicated IT or network related stuff, that’s not for me.&lt;/p&gt;  &lt;p&gt;I want to be able to switch to this setup (both for testing and demo environment):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;IIS Express/WebMatrix &lt;/li&gt;    &lt;li&gt;WP7 &lt;/li&gt;    &lt;li&gt;still my fantastic website hosted on IIS Express &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;you see: no Zune, no cable, just me and my device (and Visual Studio of course). To obtain this we need to make IIS Express able to accept connections from the outside, you can do that following this guide:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx"&gt;http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here’s what I had to do in order to make things work:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Get your computer IP, mine was: 192.168.1.10. &lt;/li&gt;    &lt;li&gt;Pickup a port you will use to host your service (using port 80 is bad idea on a development machine), I choose: 24778. &lt;/li&gt;    &lt;li&gt;Configure HTTP.SYS (the component that is used to handle http requests) to accept external connection when running as standard user (you can bypass this if you launch WebMatrix and IIS Express with admin privileges, but that’s not good for security reasons), open a shell prompt with admin rights and type:      &lt;br /&gt;      &lt;br /&gt;      &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:1c12b135-8b7d-43fe-ac13-09d3ebe28a86" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: plain; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; "&gt;netsh http add urlacl url=http://192.168.1.10:24778/ user=everyone
&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;Configure the binding in WebMatrix: doing it by manually editing the &lt;strong&gt;applicationhost.config&lt;/strong&gt; file is the best way. The file is located is your user profile at the following folder: “%USERPROFILE%\documents\IISExpress\config”. Another way to find it is: right click on the IIS Express icon in the system Tray, choose “show all applications”, highlight your website and then look at the configuration setting (it’s the last voice on the window), you can even click on it to open the file in notepad. 

    &lt;br /&gt;

    &lt;br /&gt;&lt;a href="http://www.primordialcode.com/UserFiles/Guardian/WebMatrixWp7_1.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 4px 10px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="WebMatrixWp7_1" border="0" alt="WebMatrixWp7_1" src="http://www.primordialcode.com/UserFiles/Guardian/WebMatrixWp7_1_thumb.png" width="687" height="278" /&gt;&lt;/a&gt; 

    &lt;br /&gt;The image is in Italian, I know &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Open-mouthed smile" src="http://www.primordialcode.com/UserFiles/Guardian/wlEmoticon-openmouthedsmile_2_12.png" /&gt;; now that you have your file open you need to locate the your website configuration and change the binding settings to allow connection the pre-defined IP address and port. Here’s how I modified my configuration: 

    &lt;br /&gt;

    &lt;br /&gt;

    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:d5968c44-a33d-414f-97b5-7195319b8adb" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: plain; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; "&gt;&amp;lt;site name=&amp;quot;MyWonderfulSite&amp;quot; id=&amp;quot;2&amp;quot;&amp;gt;
 &amp;lt;application path=&amp;quot;/&amp;quot;&amp;gt;
     &amp;lt;virtualDirectory path=&amp;quot;/&amp;quot; physicalPath=&amp;quot;D:\XXXXXXXXXX&amp;quot; /&amp;gt;
 &amp;lt;/application&amp;gt;
 &amp;lt;bindings&amp;gt;
     &amp;lt;binding protocol=&amp;quot;http&amp;quot; bindingInformation=&amp;quot;*:24778:localhost&amp;quot; /&amp;gt;   
     &amp;lt;binding protocol=&amp;quot;http&amp;quot; bindingInformation=&amp;quot;192.168.1.10:24778:&amp;quot; /&amp;gt;   
 &amp;lt;/bindings&amp;gt;
&amp;lt;/site&amp;gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

    &lt;br /&gt;I have added a binding that explicitly configure the IP address and port that I want to use without assigning a hostname. 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;The last step is to open up the port in your Firewall, this is up to you depending on the Firewall you are using. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If you have followed all the steps you are now able to browse your test website (using the specified address like: &lt;a href="http://192.168.1.10:24778/"&gt;http://192.168.1.10:24778/&lt;/a&gt;) from your WP7 without having the USB cable connected and Zune open, pretty cool isn’t it ?&lt;/p&gt;

&lt;p&gt;These very same steps can be used for your Android and iPhone devices, but I personally do not own any of those devices so I wasn’t able to try it.&lt;/p&gt;

&lt;p&gt;Doing this research I’ve learned a couple of things about IIS Express and how the http requests are served by the system.&lt;/p&gt;

&lt;p&gt;As last note: to undo the modifications you’ve done to the HTTP.SYS configuration you can use the following command:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:4d6c501d-59eb-4e5d-8a55-b1cf587575f3" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: plain; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; "&gt;netsh http delete urlacl url=http://192.168.1.10:24778/&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;See you next.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=TaUQCiF7unk:WuhGmeyULa4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=TaUQCiF7unk:WuhGmeyULa4:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=TaUQCiF7unk:WuhGmeyULa4:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=TaUQCiF7unk:WuhGmeyULa4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=TaUQCiF7unk:WuhGmeyULa4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=TaUQCiF7unk:WuhGmeyULa4:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=TaUQCiF7unk:WuhGmeyULa4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=TaUQCiF7unk:WuhGmeyULa4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=TaUQCiF7unk:WuhGmeyULa4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/TaUQCiF7unk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/TaUQCiF7unk/configure-webmatrix-iis-express-wp7-windows7</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/configure-webmatrix-iis-express-wp7-windows7#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/configure-webmatrix-iis-express-wp7-windows7</guid><pubDate>Tue, 07 Feb 2012 17:15:34 GMT</pubDate><category>IIS Express</category><category>WebMatrix</category><category>WP7</category><category>Android</category><category>IPhone</category><feedburner:origLink>http://www.primordialcode.com/blog/post/configure-webmatrix-iis-express-wp7-windows7</feedburner:origLink></item><item><title>Windows 7 ATIKMPAG.SYS BSOD Solved (in my case)</title><description>&lt;p&gt;After having updated the drivers for my graphic card to the latest version - Catalyst 10.12 as I write this post - taken directly from the ATI website, I started to experiment some Blue Screen Of Death (BSOD) at the startup of the OS.&lt;/p&gt;  &lt;p&gt;More specifically it all was happening when the Catalyst CCC was about to be fully loaded.&lt;/p&gt;  &lt;p&gt;The error message reported by the system was something like: “atikmpag.sys has stopped responding”, followed by the memory dump.&lt;/p&gt;  &lt;p&gt;I tried some solutions found on the internet but nothing worked: I kept having the BSOD at the startup; I tried reinstalling the drivers but neither that has worked, I even tried some old versions of the drivers with no luck.&lt;/p&gt;  &lt;p&gt;I was however able to startup the machine in recovery mode, so I started looking for some files left behind by the Uninstall manager: in my private profile directory I found a file that was storing all the drivers settings and customization that were made during the previous months. That file (called Profiles.xml) was not removed during the uninstall process, looking into that I’ve found some settings that turned to be the cause of my troubles with the new drivers.&lt;/p&gt;  &lt;p&gt;To solve this issue just delete the “Profiles.xml” you can find in the user profile directory: ‘C:\Users\YOURUSERNAME\AppData\Local\ATI\ACE’; at the next restart this file will be recreated by the system with the default settings.&lt;/p&gt;  &lt;p&gt;Maybe in the past I installed some gaming profile that caused some problems or tried some ‘experimental’ configuration to improve performances that was causing troubles, I don’t really know and, actually, I don’t really care &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Open-mouthed smile" src="http://www.primordialcode.com/UserFiles/Guardian/wlEmoticon-openmouthedsmile_2_11.png" /&gt;, but resetting it to the default values solved the problem for me avoiding a complete OS installation from scratch.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=YLHWHw8WgHM:OYIjaH8NQkI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=YLHWHw8WgHM:OYIjaH8NQkI:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=YLHWHw8WgHM:OYIjaH8NQkI:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=YLHWHw8WgHM:OYIjaH8NQkI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=YLHWHw8WgHM:OYIjaH8NQkI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=YLHWHw8WgHM:OYIjaH8NQkI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=YLHWHw8WgHM:OYIjaH8NQkI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=YLHWHw8WgHM:OYIjaH8NQkI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=YLHWHw8WgHM:OYIjaH8NQkI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/YLHWHw8WgHM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/YLHWHw8WgHM/windows-7-atikmpag.sys-bsod-solved-in-my-case</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/windows-7-atikmpag.sys-bsod-solved-in-my-case#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/windows-7-atikmpag.sys-bsod-solved-in-my-case</guid><pubDate>Thu, 02 Feb 2012 17:01:09 GMT</pubDate><category>ATI</category><category>BSOD</category><category>ATIKMPAG.SYS</category><feedburner:origLink>http://www.primordialcode.com/blog/post/windows-7-atikmpag.sys-bsod-solved-in-my-case</feedburner:origLink></item><item><title>HP ProLiant MicroServer, Windows 7 or Vista installation issues</title><description>&lt;p&gt;Stating at what HP says installing Windows Vista or Windows 7 on an HP ProLiant MicroServer (in my case the old N36L model) is not supported. This doesn’t mean it isn’t doable.&lt;/p&gt;  &lt;p&gt;All you need are the correct drivers to start the setup properly, I had an old license of Windows Vista (32 bit...ouch!) I wasn’t using anymore, so I’ve decided to install it over this piece of hardware to do some testing at my home. &lt;/p&gt;  &lt;p&gt;First problem I faced was the missing of a driver for the RAID controller (yes I set it up to use RAID 1 through the BIOS settings); once I figured out it has an AMD SATA/RAID Controller on board I started looking around for some drivers, the following package worked for me:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.primordialcode.com/userfiles/guardian/sp48266.zip"&gt;AMD SATA/RAID AHCI Controller Driver (VERSION: 3.2.1548.37 REV: G)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Just unzip it to a folder on your USB flash drive and extract the content of the ‘exe’ file (do not run or install it), you can do it using lots of free utilities out there (WinRar, just to name one).&lt;/p&gt;  &lt;p&gt;During the setup you will need to chose on which driver install Windows, if you don’t see any drive available (as it was in my case, having built a RAID array and a logical disk), you will need to fed the setup with the correct raid controller drivers. The drivers are located in the following path inside the previously extracted directory: \sp48266\RAID7xx. There will be x86 or x64 versions of the driver, chose the one that match your OR.&lt;/p&gt;  &lt;p&gt;At this point the setup will go on and everything will be installed correctly. &lt;/p&gt;  &lt;p&gt;Next step is to use ‘Windows Update’ to finish off the installation (protect the system, keep everything updated, install eventually missing drivers and so on...), but wait...we have no valid driver for the Network Card...sob &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Open-mouthed smile" src="http://www.primordialcode.com/UserFiles/Guardian/wlEmoticon-openmouthedsmile_2_10.png" /&gt;; once again let’s look for some information and drivers.&lt;/p&gt;  &lt;p&gt;The actual network card happens to be identified like: ‘HP NC107i PCIe Gigabit Server Adapter’ and it’s made by Broadcom, looking around a bit I was able to find&amp;#160; a list of standard drivers from the Broadcom website:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.broadcom.com/support/ethernet_nic/netxtreme_server.php"&gt;NetXtreme I Server&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Pick the ones that correspond to your OS and:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Extract the content in a folder or USB drive. &lt;/li&gt;    &lt;li&gt;Open up the Control Panel and go to the device management, highlight the missing network card, right click on it and choose update drivers. &lt;/li&gt;    &lt;li&gt;Navigate to the directory where you previously extracted the drivers and install them. &lt;/li&gt;    &lt;li&gt;Reboot the system (this is required for the drivers to be able to work). &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Forcing these drivers in my case it made the things work; now I’m able to browse my network and install updates.&lt;/p&gt;  &lt;p&gt;Some information about the hardware you can find inside a ProLiant MicroServer were taken out from the HP product sheet and the ‘support and drivers’ pages at the following url:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://h20000.www2.hp.com/bizsupport/TechSupport/ProductList.jsp?lang=en&amp;amp;cc=us&amp;amp;taskId=135&amp;amp;prodTypeId=15351&amp;amp;prodSeriesId=4248009"&gt;http://h20000.www2.hp.com/bizsupport/TechSupport/ProductList.jsp?lang=en&amp;amp;cc=us&amp;amp;taskId=135&amp;amp;prodTypeId=15351&amp;amp;prodSeriesId=4248009&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Maybe this post can help someone that is having my same issues.&lt;/p&gt;&lt;h2&gt;Related Content&lt;/h2&gt;&lt;ul&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/build-windows-8"&gt;Build: Windows 8&lt;/a&gt; (9/14/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/winforms-improving-rendering-performances-backgroundimage-backgroundimagelayout"&gt;Winforms: improving rendering performances with BackgroundImage and BackgroundImageLayout&lt;/a&gt; (6/30/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/a-windows-live-essentials-suite-beta-is-out.hot-to-workaround-the-no-internet-connection-setup-problem"&gt;A Windows Live Essentials Suite Beta is out...hot to workaround the ‘no internet connection’ setup problem&lt;/a&gt; (8/18/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/a-windows-live-essentials-suite-beta-is-out-hot-to-workaround-the-no-internet-connection-setup-problem"&gt;A Windows Live Essentials Suite Beta is out...how to workaround the ‘no internet connection’ setup problem&lt;/a&gt; (8/18/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/dexter-dynamic-pages-windows-live-writer-support"&gt;Dexter is growing: Dynamic Pages and better Windows Live Writer support&lt;/a&gt; (6/2/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="/Blog/Related/hp-proliant-microserver-windows-7-or-vista-installation-issues"&gt;&lt;strong&gt;More related document (6)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=pCfL17piaB8:5a4rhZ2u99Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=pCfL17piaB8:5a4rhZ2u99Q:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=pCfL17piaB8:5a4rhZ2u99Q:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=pCfL17piaB8:5a4rhZ2u99Q:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=pCfL17piaB8:5a4rhZ2u99Q:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=pCfL17piaB8:5a4rhZ2u99Q:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=pCfL17piaB8:5a4rhZ2u99Q:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=pCfL17piaB8:5a4rhZ2u99Q:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=pCfL17piaB8:5a4rhZ2u99Q:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/pCfL17piaB8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/pCfL17piaB8/hp-proliant-microserver-windows-7-or-vista-installation-issues</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/hp-proliant-microserver-windows-7-or-vista-installation-issues#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/hp-proliant-microserver-windows-7-or-vista-installation-issues</guid><pubDate>Tue, 13 Dec 2011 20:28:36 GMT</pubDate><category>HP</category><category>ProLiant</category><category>Windows 7</category><category>Windows Vista</category><feedburner:origLink>http://www.primordialcode.com/blog/post/hp-proliant-microserver-windows-7-or-vista-installation-issues</feedburner:origLink></item><item><title>Creating a ‘Windows Installation’ bootable USB drive</title><description>&lt;p&gt;Recently I was in need to setup some new hardware and I’ve found myself doing this procedure over and over (because I am a cheap b*****d and I only own few USB pen drives &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Open-mouthed smile" src="http://www.primordialcode.com/UserFiles/Guardian/wlEmoticon-openmouthedsmile_2_9.png" /&gt;) again. So even if there are plenty of posts out there offering more or less the same content, I’ll write it down here as a reminder to myself.&lt;/p&gt;  &lt;p&gt;Consider you can use this very same procedure to create a bootable USB flash drive to install any Microsoft Windows OS (from Vista to 2008 Server R2).&lt;/p&gt;  &lt;h3&gt;Prepare and Format the drive&lt;/h3&gt;  &lt;p&gt;You can do these first steps in several way, I prefer to use the &lt;strong&gt;diskpart&lt;/strong&gt; command line utility; BE CAREFUL HERE! If you do something wrong you may easily wipeout you disks!&amp;#160; &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Open a command prompt as administrator (Right click on Start &amp;gt; All Programs &amp;gt; Accessories &amp;gt; Command Prompt and select “Run as administrator”)      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;type the following commands into the Command Prompt Window:      &lt;br /&gt;      &lt;br /&gt;&amp;#160; diskpart       &lt;br /&gt;      &lt;br /&gt;&amp;#160; list disk       &lt;br /&gt;      &lt;br /&gt;This will bring up a list of all your physical drives installed; look for your USB drive and take note of the number; if you have multiple USB drives attached I suggest you to disconnect them all but the one you want to use: the only way to identify the drive is looking at the drive’s size in this step, having multiple USB drives with the same capacity is not good!       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Format the drive by typing the following commands into the same window. Replace “X” with the number of your disk.      &lt;br /&gt;      &lt;br /&gt;select disk X      &lt;br /&gt;      &lt;br /&gt;clean       &lt;br /&gt;      &lt;br /&gt;create partition primary      &lt;br /&gt;       &lt;br /&gt;select partition 1       &lt;br /&gt;      &lt;br /&gt;active       &lt;br /&gt;      &lt;br /&gt;format fs=NTFS       &lt;br /&gt;      &lt;br /&gt;assign       &lt;br /&gt;      &lt;br /&gt;exit       &lt;br /&gt;      &lt;br /&gt;At this stage we have a clean formatted USB with an active partition ready to be made bootable. Some guides will tell you to format the pen drive using FAT32, I always prefer to use NTFS especially to create bootable winpe drives to use the imagex.exe utility to clone systems, in this scenario we can easily break through the FAT32 file size limit.&lt;/li&gt; &lt;/ol&gt;  &lt;h3&gt;Make the drive bootable&lt;/h3&gt;  &lt;p&gt;To make the drive bootable we will use the &lt;strong&gt;bootsect&lt;/strong&gt; utility that comes along with any Microsoft Windows OS:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Insert your OS DVD.     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Change directory to X:\boot (where X is your dvd drive).     &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Type the following instruction to make the drive bootable (now ‘X’ is your pen drive).     &lt;br /&gt;      &lt;br /&gt;bootsect /nt60 X:      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Close the Command Prompt Window.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The last step is copy all your installation files from the DVD (or ISO) to your newly created bootable USB flash drive.&lt;/p&gt;  &lt;p&gt;If you do not want to do everything by hand, there’s a tool from Microsoft you can use to do the very same work: &lt;a href="http://www.microsoftstore.com/store/msstore/html/pbPage.Help_Win7_usbdvd_dwnTool"&gt;Windows 7 USB/DVD download tool&lt;/a&gt;.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=2UnXmAyMLLk:TkdR34G4lQY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=2UnXmAyMLLk:TkdR34G4lQY:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=2UnXmAyMLLk:TkdR34G4lQY:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=2UnXmAyMLLk:TkdR34G4lQY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=2UnXmAyMLLk:TkdR34G4lQY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=2UnXmAyMLLk:TkdR34G4lQY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=2UnXmAyMLLk:TkdR34G4lQY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=2UnXmAyMLLk:TkdR34G4lQY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=2UnXmAyMLLk:TkdR34G4lQY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/2UnXmAyMLLk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/2UnXmAyMLLk/creating-a-windows-installation-bootable-usb-drive</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/creating-a-windows-installation-bootable-usb-drive#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/creating-a-windows-installation-bootable-usb-drive</guid><pubDate>Tue, 13 Dec 2011 01:19:44 GMT</pubDate><category>Usb</category><category>Boot</category><feedburner:origLink>http://www.primordialcode.com/blog/post/creating-a-windows-installation-bootable-usb-drive</feedburner:origLink></item><item><title>Build: Windows 8</title><description>&lt;p&gt;I bet almost all the developers followed the ‘build’ keynote Yesterday, we had some big news (nothing too much scary, thankfully) and we saw Windows running on a bunch of new devices (I honestly can’t wait to put my hands on them) that will hit the market sooner or later in the future.&lt;/p&gt;  &lt;p&gt;On the Dev side, I’m very excited for what we saw: new potentials, some big improvements and a potentially rewritten and optimized infrastructure over which your apps will run on. I loved the metro style UI on WP7 and this ‘bigger brother’ seems very good to me. And yes the ‘pro’ will have their usual desktop view too (with productivity improvements on that side too).&lt;/p&gt;  &lt;p&gt;On the consumer and business side, timing here is quite important: when this new beast will be released to the market ? will it be too late to compete against its ‘enemies’ ? when the new devices will be available ? and another one... pricing ? will it get a good welcome from the customers? we can go on and on and on... &lt;/p&gt;  &lt;p&gt;Windows 8 should focus its target on the new devices and new installations, because hoping that a big part of the pre-existing windows installed machine will be updated to windows 8 in the close future is just...well...chose your word here!.&lt;/p&gt;  &lt;p&gt;Here in Italy before updating any windows version to the new one the usual policy is to ‘wait for the SP1’, people is just scared of changes (and of course the ‘money factor’ plays its main role too, which will stops many businesses to early adopt it).&lt;/p&gt;  &lt;p&gt;While we wait and think about all of this, we (devs) can happily put our hands on a Developer Preview of Windows 8, head up to MSDN for more info or just follow these links:&lt;/p&gt;  &lt;p&gt;Windows Developer Preview: &lt;a href="http://msdn.microsoft.com/en-us/windows/apps/br229516"&gt;http://msdn.microsoft.com/en-us/windows/apps/br229516&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Build Keynote &amp;amp; sessions info: &lt;a href="http://www.microsoft.com/presspass/events/build/"&gt;http://www.microsoft.com/presspass/events/build/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Build sessions will be available through Channel 9: &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011?sort=sequential&amp;amp;direction=desc&amp;amp;term"&gt;http://channel9.msdn.com/Events/BUILD/BUILD2011?sort=sequential&amp;amp;direction=desc&amp;amp;term&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Time to have some fun (again)!&lt;/p&gt;&lt;h2&gt;Related Content&lt;/h2&gt;&lt;ul&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/winforms-improving-rendering-performances-backgroundimage-backgroundimagelayout"&gt;Winforms: improving rendering performances with BackgroundImage and BackgroundImageLayout&lt;/a&gt; (6/30/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/a-windows-live-essentials-suite-beta-is-out.hot-to-workaround-the-no-internet-connection-setup-problem"&gt;A Windows Live Essentials Suite Beta is out...hot to workaround the ‘no internet connection’ setup problem&lt;/a&gt; (8/18/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/a-windows-live-essentials-suite-beta-is-out-hot-to-workaround-the-no-internet-connection-setup-problem"&gt;A Windows Live Essentials Suite Beta is out...how to workaround the ‘no internet connection’ setup problem&lt;/a&gt; (8/18/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/dexter-dynamic-pages-windows-live-writer-support"&gt;Dexter is growing: Dynamic Pages and better Windows Live Writer support&lt;/a&gt; (6/2/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/hp-proliant-microserver-windows-7-or-vista-installation-issues"&gt;HP ProLiant MicroServer, Windows 7 or Vista installation issues&lt;/a&gt; (12/13/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="/Blog/Related/build-windows-8"&gt;&lt;strong&gt;More related document (6)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=T7whey93OVg:Ic4YRpowmLw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=T7whey93OVg:Ic4YRpowmLw:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=T7whey93OVg:Ic4YRpowmLw:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=T7whey93OVg:Ic4YRpowmLw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=T7whey93OVg:Ic4YRpowmLw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=T7whey93OVg:Ic4YRpowmLw:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=T7whey93OVg:Ic4YRpowmLw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=T7whey93OVg:Ic4YRpowmLw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=T7whey93OVg:Ic4YRpowmLw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/T7whey93OVg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/T7whey93OVg/build-windows-8</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/build-windows-8#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/build-windows-8</guid><pubDate>Wed, 14 Sep 2011 17:13:25 GMT</pubDate><category>Windows 8</category><category>Build</category><feedburner:origLink>http://www.primordialcode.com/blog/post/build-windows-8</feedburner:origLink></item><item><title>NHibernate.Envers - Customize the Revision Entity</title><description>&lt;p&gt;Sometimes the basic information provided by the default revision entity we have in &lt;a href="http://nhforge.org/"&gt;NHibernate&lt;/a&gt;.Envers are not enough, when we need to extend those information and provide additional data we have the option to use a customized version of the Revision Entity class.&lt;/p&gt;  &lt;p&gt;The default revision entity is defined like this:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:b80f4206-297b-417c-9f8b-8bea7f86978c" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;[Serializable]
public class DefaultRevisionEntity
{
	[RevisionNumber]
	public virtual int Id { get; set; }

	[RevisionTimestamp]
	public virtual DateTime RevisionDate { get; set; }

	public override bool Equals(object obj)
	{
		if (this == obj) return true;
		var revisionEntity = obj as DefaultRevisionEntity;
		if (revisionEntity == null) return false;

		var that = revisionEntity;

		if (Id != that.Id) return false;
		return RevisionDate == that.RevisionDate;
	}

	public override int GetHashCode()
	{
		var result = Id;
		result = 31 * result + (int)(((ulong)RevisionDate.Ticks) ^ (((ulong)RevisionDate.Ticks) &amp;gt;&amp;gt; 32));
		return result;
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;You can notice two properties that defines the information that a Revision Entity class MUST have, they are also marked by two configuration attributes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;[RevisionNumber] - states which property will represent the revision number of the version&lt;/li&gt;

  &lt;li&gt;[RevisionTimestamp] - states the timestamp of the version&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every custom Revision Entity class MUST have these two kind of properties, once again we will use the fluent by code configuration so we will not need to decorate our classes with attributes (I’ll show how to configure NHibernate.Envers using attributes in another post).&lt;/p&gt;

&lt;p&gt;Our custom Revision Entity class for this example will be:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:45d82845-8a30-4d84-870e-d04e3a103058" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;//[RevisionEntity]
public class REVINFO
{
	//[RevisionNumber]
	public virtual long Id { get; set; }

	//[RevisionTimestamp]
	public virtual DateTime CustomTimestamp { get; set; }

	public virtual string Data { get; set; }

	public override bool Equals(object obj)
	{
		var casted = obj as REVINFO;
		if (casted == null)
			return false;
		return (Id == casted.Id &amp;amp;&amp;amp;
				CustomTimestamp.Equals(casted.CustomTimestamp) &amp;amp;&amp;amp;
				Data.Equals(casted.Data));
	}

	public override int GetHashCode()
	{
		return Id.GetHashCode() ^ CustomTimestamp.GetHashCode() ^ Data.GetHashCode();
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;As you can see we have the two basic properties plus an additional Data field that will represent our custom data added to each revision tracked.&lt;/p&gt;

&lt;p&gt;To be able to fill these data we need to implement a particular type of interface: an &lt;strong&gt;IRevisionListener&lt;/strong&gt;. This interface expose only a single member function - void NewRevision(object) - and it’s called every time a new revision object is generated. The demo code is:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:c30908fa-da7a-42a0-96c1-f97b5e0ade79" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;public class RevInfoListener : IRevisionListener
{
	public static string Data = &amp;quot;test data&amp;quot;;

	public void NewRevision(object revisionEntity)
	{
		((REVINFO)revisionEntity).Data = Data;
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;The last step is to change the configuration to ‘inject’ our custom Revision Entity class and Listener; in my test project I do it with the following code:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:d27bdda2-ba09-4c44-8856-2b6c71a5dc9d" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; "&gt;public class NHinitCustomRevInfo : NHibernateInitializer
{
	protected override System.Collections.Generic.IEnumerable&amp;lt;System.Type&amp;gt; GetDomainEntities()
	{
		// I am using ConfORM to emit the mappings, so we add it to the mapped classes.
		return base.GetDomainEntities().Union(new[] { typeof(REVINFO) });
	}
	
	protected override void ConfOrmMapping(ConfOrm.ObjectRelationalMapper orm, ConfOrm.NH.Mapper mapper)
	{
		// I have to provide a mapping for a custom RevInfo class...NHibernate must know how to handle these objects
		orm.TablePerClass&amp;lt;REVINFO&amp;gt;();
		
		orm.TablePerClass&amp;lt;Person&amp;gt;();
		orm.TablePerClass&amp;lt;Game&amp;gt;();
	}

	public void InitializeAudit()
	{
		// initialize the NHibernate.Envers fluent configuration object
		var enversConf = new NHibernate.Envers.Configuration.Fluent.FluentConfiguration();

		// I prefer to not use attributes to configure the custom revision entity
		enversConf.SetRevisionEntity&amp;lt;REVINFO&amp;gt;(e =&amp;gt; e.Id, e =&amp;gt; e.CustomTimestamp, typeof(RevInfoListener));
		
		// the RevInfo class must not be in the auditing list
		enversConf.Audit(GetDomainEntities().Where(e =&amp;gt; !typeof(REVINFO).IsAssignableFrom(e)));

		// to inspect the metadata
		//var mets = enversConf.CreateMetaData(Configure);

		// Configure.Properties.Add(&amp;quot;nhibernate.envers.audit_table_prefix&amp;quot;, string.Empty); // default
		Configure.Properties.Add(&amp;quot;nhibernate.envers.audit_table_suffix&amp;quot;, &amp;quot;_REV&amp;quot;); // default _AUD
		// Configure.Properties.Add(&amp;quot;nhibernate.envers.revision_field_name&amp;quot;, &amp;quot;REV&amp;quot;); // default
		// Configure.Properties.Add(&amp;quot;nhibernate.envers.revision_type_field_name&amp;quot;, &amp;quot;REVTYPE&amp;quot;); // default

		Configure.IntegrateWithEnvers(enversConf);
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;I am using &lt;a href="http://code.google.com/p/codeconform/" target="_blank"&gt;ConfORM&lt;/a&gt; and my mapping engine, so part of the configuration is related to how it’s used to generate the mappings, but the concepts are valid for any other mapping tools you use; Let’s go through it:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Line 6: we add the REVINFO class to my mapped domain, ConfORM need to be aware of it.&lt;/li&gt;

  &lt;li&gt;Line 12: we tell ConfORM how to map the class.&lt;/li&gt;

  &lt;li&gt;Line 21: we initialize the NHibernate.Envers fluent configuration engine.&lt;/li&gt;

  &lt;li&gt;Line 24: this is the crucial point, we specify our custom Revision Entity class type, we tell Envers which functions to use to fill in the Revision incremental number and the Revision Timestamp; plus we pass in the type of the IRevisionListener implementation if we want to specify additional data in the custom revision entity class.&lt;/li&gt;

  &lt;li&gt;Line 27: we tell to NHibernate.Envers which classes we want to track (be careful to exclude the REVINFO class from the tracked ones here).&lt;/li&gt;

  &lt;li&gt;Line 37: we add NHibernate.Envers to the standard NHibernate configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we create a simple test and execute it we can inspect the schema of the generated database to see the custom revision entity in place:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.primordialcode.com/UserFiles/Guardian/NHibernateEnversSampleSchemaCustomRevEnt_2.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 4px 10px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Database Schema with Custom Revision Entity" border="0" alt="Database Schema with Custom Revision Entity" src="http://www.primordialcode.com/UserFiles/Guardian/NHibernateEnversSampleSchemaCustomRevEnt_thumb.jpg" width="554" height="467" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 1 - Database Schema with Custom Revision Entity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That’s all for this post, next time we’ll see how to query for the extended revision entity properties we just added.&lt;/p&gt;&lt;h2&gt;Related Content&lt;/h2&gt;&lt;ul&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-envers-quick-introduction"&gt;NHibernate.Envers - a quick introduction&lt;/a&gt; (6/7/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-envers-querying-part-1"&gt;NHibernate.Envers - Querying - part 1&lt;/a&gt; (6/10/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-envers-querying-part-2"&gt;NHibernate.Envers - Querying - part 2&lt;/a&gt; (7/13/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/silverlight-wcf-fixing-custom-wcf-proxy-generator"&gt;Silverlight / WCF: fixing the Custom WCF Proxy Generator&lt;/a&gt; (12/16/2009)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/silverlight-wcf-writing-custom-wcf-proxy-generator-support-validation"&gt;Silverlight / WCF : Writing your own Custom WCF Proxy Generator to support validation&lt;/a&gt; (12/9/2009)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="/Blog/Related/nhibernate-envers-customize-revision-entity"&gt;&lt;strong&gt;More related document (4)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=8vSD5cvoUOc:60q182ZZD60:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=8vSD5cvoUOc:60q182ZZD60:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=8vSD5cvoUOc:60q182ZZD60:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=8vSD5cvoUOc:60q182ZZD60:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=8vSD5cvoUOc:60q182ZZD60:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=8vSD5cvoUOc:60q182ZZD60:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=8vSD5cvoUOc:60q182ZZD60:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=8vSD5cvoUOc:60q182ZZD60:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=8vSD5cvoUOc:60q182ZZD60:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/8vSD5cvoUOc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/8vSD5cvoUOc/nhibernate-envers-customize-revision-entity</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/nhibernate-envers-customize-revision-entity#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/nhibernate-envers-customize-revision-entity</guid><pubDate>Fri, 05 Aug 2011 21:10:17 GMT</pubDate><category>Nhibernate.Envers</category><category>Custom</category><feedburner:origLink>http://www.primordialcode.com/blog/post/nhibernate-envers-customize-revision-entity</feedburner:origLink></item><item><title>Sql Server - Scramble / Mask database production data</title><description>&lt;p&gt;Sometimes you might need to test your product using some ‘production’ data to better simulate what users do with your software.&lt;/p&gt;  &lt;p&gt;There are situations in which having only your test database, with your own (well formed) test data is not enough: just think of a continuously growing database with frequent schema changes...you might likely have inconsistencies between the data as you upgrade it or unpredicted behaviors.&lt;/p&gt;  &lt;p&gt;If you want use a copy or a snapshot of a production database for test purposes, you should at least try to hide the sensitive data away (in a way that is really hard or impossible for your development team or anyone else that have access to the database to reconstruct them).&lt;/p&gt;  &lt;p&gt;As you can imagine the task here can be extremely difficult to accomplish and there might be some tools out there that can help you doing this job.&lt;/p&gt;  &lt;p&gt;If you do not want to invest in them a quick and dirty solution (it took me more or less 15 minutes to put it all together, and I’m not a SQL expert) can be writing some SQL scripts to modify what you consider to be your most sensitive data, leaving everything else intact. It doesn’t guarantee that all the sensitive data are hidden/changed because it relies on the code you write.&lt;/p&gt;  &lt;p&gt;The typical scenario is to modify the names and telephone numbers of some personal data records, but you can apply this technique to anything you want.&lt;/p&gt;  &lt;p&gt;Fist we need some functions to create test data, here you can use anything you want but I prefer something that generates data based on a prefix I can pass in; you can easily create functions that generate completely random data, but it will be hard to talk to your team and say something like: “ehi...check the person named ‘XWggTRDnnns’!”, a simple string concatenation does the job here.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:4cec6735-6ca1-4f69-be54-3a8eb4d4db45" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;--concatenates a generic string and an incremental number
CREATE FUNCTION fn_GenerateText(@prefix varchar(255), @incr int)
RETURNS varchar(255)
AS
BEGIN
return @prefix + CONVERT(varchar(100),@incr)
END
GO&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;Next we need to scan all our data tables and update the data we find there, here I decided to use a cursor (it’s not efficient but you can handle any type of key in this way, from guids to strings), so the idea is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;read each line of the table&lt;/li&gt;

  &lt;li&gt;generate some test data for each of the sensitive columns with text like: ‘name0’, ‘surname0’, etc... the number will be incremented for each line&lt;/li&gt;

  &lt;li&gt;update the data row with the given data for each of the columns you need to modify&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:7ed732a9-ab35-45e5-a545-0bcab4f9926c" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;-- a variable we use to generate incremental numbers
Declare @i int
set @i = 0

-- let's use a cursor, i don't know the data type of the key column
declare @id uniqueidentifier;
Declare id_cursor CURSOR
	FOR select AP_ID from dbo.PersonalData;
open id_cursor;
fetch next from id_cursor into @id;

WHILE @@FETCH_STATUS = 0
BEGIN

update  dbo.PersonalData
set 
AP_Note = dbo.fn_GenerateText('test', @i),
AP_FiscalCode = dbo.fn_GenerateText('fc', @i), -- or use a valid fiscal code generation routine here
AP_Surname = dbo.fn_GenerateText('surname', @i),
AP_Name = dbo.fn_GenerateText('name', @i),
AP_Phone = dbo.fn_GenerateText('t', @i),
AP_CellPhone = dbo.fn_GenerateText('c', @i)
Where AP_ID = @id 

-- increment the suffix and get the new data from the cursor
set @i = @i+1;
fetch next from id_cursor into @id;
END
CLOSE id_cursor;
DEALLOCATE id_cursor;
GO&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;/p&gt;

&lt;p&gt;In the end we just cleanup the database from every support function we created:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:d5de8880-8b28-4e97-a879-5d5843b2a2a3" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;DROP FUNCTION dbo.fn_GenerateText
GO&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;As you can see this is a very quick solution and you will have to write some SQL code and manage the relations by yourself if needed, nonetheless once you have your scripts in place it’s a quite easy solution to use and maintain.&lt;/p&gt;&lt;h2&gt;Related Content&lt;/h2&gt;&lt;ul&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-prepare_sql-considerations-mapping-long-string-fields"&gt;NHibernate - prepare_sql and some considerations on mapping very long string fields&lt;/a&gt; (8/26/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/install-sql-server-express-with-your-application"&gt;Install SQL Server (Express) with your Application&lt;/a&gt; (1/29/2009)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="/Blog/Related/sql-server-scramble-mask-database-production-data"&gt;&lt;strong&gt;More related document (1)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=INlMDCOjIrg:b_Q2OYcy3-c:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=INlMDCOjIrg:b_Q2OYcy3-c:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=INlMDCOjIrg:b_Q2OYcy3-c:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=INlMDCOjIrg:b_Q2OYcy3-c:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=INlMDCOjIrg:b_Q2OYcy3-c:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=INlMDCOjIrg:b_Q2OYcy3-c:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=INlMDCOjIrg:b_Q2OYcy3-c:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=INlMDCOjIrg:b_Q2OYcy3-c:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=INlMDCOjIrg:b_Q2OYcy3-c:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/INlMDCOjIrg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/INlMDCOjIrg/sql-server-scramble-mask-database-production-data</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/sql-server-scramble-mask-database-production-data#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/sql-server-scramble-mask-database-production-data</guid><pubDate>Wed, 27 Jul 2011 18:59:49 GMT</pubDate><category>SQL</category><category>Scramble</category><feedburner:origLink>http://www.primordialcode.com/blog/post/sql-server-scramble-mask-database-production-data</feedburner:origLink></item><item><title>Fetching collections with NHibernate, a mistake a I always do!</title><description>&lt;p&gt;I did it again! That’s why I’m writing this blog post...I do it almost every time and the main reason is: trying to optimize &lt;a href="http://nhforge.org/"&gt;NHibernate&lt;/a&gt; queries without thinking.&lt;/p&gt;  &lt;p&gt;As the title of the posts says the problem here is related to fetching the data of different collections attached to a single entity. To show you up the problem let’s first see the test domain, it is very simple:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:bcc9a39b-2139-4ed7-91b2-1835d47599d5" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;public class Post : Entity&amp;lt;int&amp;gt;
{
	protected Post()
	{
	}

	public Post(string slug)
	{
		Slug = slug;
		Categories = new List&amp;lt;Category&amp;gt;();
		Tags = new List&amp;lt;Tag&amp;gt;();
	}

	public string Slug { get; set; }

	public IList&amp;lt;Category&amp;gt; Categories { get; set; }

	public IList&amp;lt;Tag&amp;gt; Tags { get; set; }	
}

public class Category : Entity&amp;lt;int&amp;gt;
{
	public string Name { get; set; }
}

public class Tag : Entity&amp;lt;int&amp;gt;
{
	public string Name { get; set; }
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;I generated some test data consisting of a single post which has 2 categories and 2 tags associated to it.&lt;/p&gt;

&lt;p&gt;We want to query the Post object together with all it’s data, the first thing we can do is this:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:c82a353f-2fb5-4961-ac59-39fb08c75e36" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;[Test]
public void NoFetch_Success()
{
	using (ISession s = _nh.SessionFactory.OpenSession())
	{
		// look for a non existing revision
		using (var tx = s.BeginTransaction())
		{
			var p = s.CreateQuery(&amp;quot;from Post p where p.Slug = :slug&amp;quot;)
				.SetParameter(&amp;quot;slug&amp;quot;, &amp;quot;Slug&amp;quot;)
				.UniqueResult&amp;lt;Post&amp;gt;();

			tx.Commit();

			Assert.IsNotNull(p);
			Assert.AreEqual(2, p.Categories.Count);
			Assert.AreEqual(2, p.Tags.Count);
		}
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;Straightforward and simple; this thing produces 3 different queries, one for each kind of object:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:00903a7a-e0ed-4456-bcf7-862d1a5e2aa8" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;select post0_.Id as Id0_, post0_.Slug as Slug0_ from Post post0_ where post0_.Slug=@p0;@p0 = 'Slug' [Type: String (4000)]

SELECT categories0_.PostId as PostId1_, categories0_.Id as Id1_, categories0_.Id as Id1_0_, categories0_.Name as Name1_0_ FROM Category categories0_ WHERE categories0_.PostId=@p0;@p0 = 1 [Type: Int32 (0)]

SELECT tags0_.PostId as PostId1_, tags0_.Id as Id1_, tags0_.Id as Id2_0_, tags0_.Name as Name2_0_ FROM Tag tags0_ WHERE tags0_.PostId=@p0;@p0 = 1 [Type: Int32 (0)]
		&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;The returned data are all correct.&lt;/p&gt;

&lt;p&gt;But we really have too many queries here and we want to optimize it a bit (in order to limit/prevent the impact of the n+1 selects problem), so in my optimization berserker fury I started using fetch joins to retrieve more data in a single pass and I wrote this query:&lt;/p&gt;

&lt;pre&gt;from Post p left join fetch p.Categories left join fetch p.Tags where p.Slug = :slug&lt;/pre&gt;

&lt;p&gt;which is an absolute mistake, because it generates duplicated data; let’s see some test code:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:4e780514-eac5-4df3-bc7f-2d9396983ce4" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;[Test]
public void FetchALL_Failure()
{
	using (ISession s = _nh.SessionFactory.OpenSession())
	{
		// look for a non existing revision
		using (var tx = s.BeginTransaction())
		{
			// try adding a: select distinct p 
			var p = s.CreateQuery(&amp;quot;from Post p left join fetch p.Categories left join fetch p.Tags where p.Slug = :slug&amp;quot;)
				.SetParameter(&amp;quot;slug&amp;quot;, &amp;quot;Slug&amp;quot;)
				.UniqueResult&amp;lt;Post&amp;gt;();

			tx.Commit();

			Assert.IsNotNull(p);
			Assert.AreEqual(2, p.Categories.Count); // &amp;lt;- big exception... we have 4 rows
			Assert.AreEqual(2, p.Tags.Count);
		}
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;which produces 1 single query:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:5544f78b-7878-41db-ae0e-b88ac70d189c" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;select post0_.Id as Id0_0_, categories1_.Id as Id1_1_, tags2_.Id as Id2_2_, post0_.Slug as Slug0_0_, categories1_.Name as Name1_1_, categories1_.PostId as PostId0__, categories1_.Id as Id0__, tags2_.Name as Name2_2_, tags2_.PostId as PostId1__, tags2_.Id as Id1__ from Post post0_ left outer join Category categories1_ on post0_.Id=categories1_.PostId left outer join Tag tags2_ on post0_.Id=tags2_.PostId where post0_.Slug=@p0;@p0 = 'Slug' [Type: String (4000)]&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;But the data are all wrong! In fact the Assert that should check for the correct numbers of categories are telling me that I have 4 rows inside that collection. I should have reminded earlier what the NHibernate documentation says about this situation:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;It is possible to create a cartesian product by join fetching more than one collection in a query, so take care in this case. Join fetching multiple collection roles is also disabled for bag mappings. Note also that the &lt;tt&gt;fetch&lt;/tt&gt; construct may not be used in queries called using &lt;tt&gt;Enumerable()&lt;/tt&gt;. Finally, note that &lt;tt&gt;full join fetch&lt;/tt&gt; and &lt;tt&gt;right join fetch&lt;/tt&gt; are not meaningful. (Reference documentation, 13.3 Associations and joins)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Note that adding a ‘select distinct p’ will not help in this case.&lt;/p&gt;

&lt;p&gt;To fix this we need to have just one fetch join at each level of the hierarchy; we can write something like this:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:44d2dc2f-c227-4384-b6f1-5de85dc58bbb" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;var p = s.CreateQuery(&amp;quot;from Post p left join fetch p.Categories where p.Slug = :slug&amp;quot;)
						.SetParameter(&amp;quot;slug&amp;quot;, &amp;quot;Slug&amp;quot;)
						.UniqueResult&amp;lt;Post&amp;gt;();&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;This code will generate 2 queries (one to get the Post and the Categories and one to get the Tags) and the test will pass:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:c7a5bcb3-7c8f-4d81-90ec-65e8733e52ed" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;select post0_.Id as Id12_0_, categories1_.Id as Id13_1_, post0_.Slug as Slug12_0_, categories1_.Name as Name13_1_, categories1_.PostId as PostId0__, categories1_.Id as Id0__ from Post post0_ left outer join Category categories1_ on post0_.Id=categories1_.PostId where post0_.Slug=@p0;@p0 = 'Slug' [Type: String (4000)]
		
SELECT tags0_.PostId as PostId1_, tags0_.Id as Id1_, tags0_.Id as Id14_0_, tags0_.Name as Name14_0_ FROM Tag tags0_ WHERE tags0_.PostId=@p0;@p0 = 1 [Type: Int32 (0)]&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;But...wait! .UniqueResult&amp;lt;T&amp;gt;() here is smart enough to hide us a fetch join side effect; if we use .List&amp;lt;T&amp;gt;() instead we will see it clearly: the fetch introduces ‘ghosts’ in our returned resultset; the data will be a combination of Posts and Categories fields, so for any single Post object we will have ‘n’ records (one for each Category bound to the Post) and NHibernate will output ‘n’ Post entities, all of them containing the same data.&lt;/p&gt;

&lt;p&gt;The solution here is pretty simple: just add the ‘distinct’ keyword to the select statement (or use the DistinctRootEntityTransformer), this way we are telling NHibernate to give us back all the unique instances of Post objects together with their Categories, here is the code:&lt;/p&gt;

&lt;p&gt;
  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:19fe3c40-1ae7-4a6e-b379-9d5ee64a9b14" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;[Test]
public void FetchSingleCollection_Distinct_Success()
{
	using (ISession s = _nh.SessionFactory.OpenSession())
	{
		// look for a non existing revision
		using (var tx = s.BeginTransaction())
		{
			var p = s.CreateQuery(&amp;quot;select distinct p from Post p left join fetch p.Categories where p.Slug = :slug&amp;quot;)
				.SetParameter(&amp;quot;slug&amp;quot;, &amp;quot;Slug&amp;quot;)
				.UniqueResult&amp;lt;Post&amp;gt;();
			tx.Commit();

			Assert.IsNotNull(p);
			Assert.AreEqual(2, p.Categories.Count);
			Assert.AreEqual(2, p.Tags.Count);
		}
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;/p&gt;

&lt;p&gt;If I remind it well, there’s no need to use the distinct on the queries generated using Linq to NHibernate, because the provider does it for you.&lt;/p&gt;

&lt;p&gt;As usual here’s the test project for those who want to play with it:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:fbf49488-e8fb-4ef2-b02d-7491959571f0" class="wlWriterEditableSmartContent"&gt;&lt;p&gt;&lt;div&gt;&lt;a href="http://www.primordialcode.com/UserFiles/Guardian/NHibernateTestsCollectionFetching.zip" target="_self"&gt;NHibernateTestsCollectionFetching.zip&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;I am hoping, now that I’ve wrote it down, to not make the same mistake again &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Open-mouthed smile" src="http://www.primordialcode.com/UserFiles/Guardian/wlEmoticon-openmouthedsmile_2_8.png" /&gt;...&lt;/p&gt;&lt;h2&gt;Related Content&lt;/h2&gt;&lt;ul&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-eager-fetch-order-strange-behavior-icriteria"&gt;NHibernate - Eager Fetch, Order By and a strange behavior with ICriteria&lt;/a&gt; (7/13/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/breaking-news-european-nhibernate-day-officially-announced"&gt;Breaking news: the First European NHibernate Day had been officially announced&lt;/a&gt; (5/20/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-impressions-conform"&gt;NHibernate - First impressions on ConfORM&lt;/a&gt; (9/24/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-customize-linq-provider-user-defined-sql-functions"&gt;NHibernate - Customize the Linq provider to call your user defined SQL functions&lt;/a&gt; (10/1/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/the-nhibernate-day-is-coming.this-saturday"&gt;The NHibernate Day is coming...this Saturday!&lt;/a&gt; (10/6/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="/Blog/Related/fetching-collections-nhibernate-mistake"&gt;&lt;strong&gt;More related document (21)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=ofBa5zQlRvY:YlLQ7w-hghQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=ofBa5zQlRvY:YlLQ7w-hghQ:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=ofBa5zQlRvY:YlLQ7w-hghQ:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=ofBa5zQlRvY:YlLQ7w-hghQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=ofBa5zQlRvY:YlLQ7w-hghQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=ofBa5zQlRvY:YlLQ7w-hghQ:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=ofBa5zQlRvY:YlLQ7w-hghQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=ofBa5zQlRvY:YlLQ7w-hghQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=ofBa5zQlRvY:YlLQ7w-hghQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/ofBa5zQlRvY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/ofBa5zQlRvY/fetching-collections-nhibernate-mistake</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/fetching-collections-nhibernate-mistake#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/fetching-collections-nhibernate-mistake</guid><pubDate>Wed, 20 Jul 2011 00:52:37 GMT</pubDate><category>NHibernate</category><category>Fetch</category><feedburner:origLink>http://www.primordialcode.com/blog/post/fetching-collections-nhibernate-mistake</feedburner:origLink></item><item><title>NHibernate.Envers - Querying - part 2</title><description>&lt;p&gt;In the previous articles of this series we saw how to initialize the environment to use &lt;a href="http://nhforge.org/"&gt;NHibernate&lt;/a&gt;.Envers and how to query it for getting information about the revisions it creates.&lt;/p&gt;  &lt;p&gt;It’s now time to focus on the methods that allows us to actually retrieve the different revisions details (such as the state of the whole entity at a given revision and similar) and the history of the modifications an object has been subject to.&lt;/p&gt;  &lt;p&gt;Once again our operation entry point is the &lt;strong&gt;IAuditReader&lt;/strong&gt; object, but this time we will use its &lt;strong&gt;CreateQuery&lt;/strong&gt;() method.&lt;/p&gt;  &lt;p&gt;CreateQuery() returns an &lt;strong&gt;AuditQueryCreator&lt;/strong&gt; object that exposes all the functions we need to perform search queries against the database; AuditQueryCreator provides a series of normal methods that specifies the entity we want to look for using a typeof(T) argument as their first parameter. It also exposes the generic version of those methods and we’ll focus our attention on those (because I hate to write down typeof() everywhere, if I can avoid it), the non generic functions are however very similar and their usage should be clear anyway.&lt;/p&gt;  &lt;p&gt;Each of these generic functions will return an &lt;strong&gt;IEntityAuditQuery&amp;lt;T&amp;gt;&lt;/strong&gt; object, these kind of objects work exactly like the usual NHibernate ICriteria API: we can add search criteria to filter out the results, order the results, perform pagination, add projections and so on.&lt;/p&gt;  &lt;p&gt;To get the results from an IEntityAuditQuery object we can use two methods:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;.Single() - it will return a single instance of the class representing the result, or an exception if more than one result is available. &lt;/li&gt;    &lt;li&gt;.Results() - it will return an enumeration of the class representing the result. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Actually we have tree different methods we can use to build up queries against our revision database tables, let’s see them in detail:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;ForEntitiesAtRevision&amp;lt;T&amp;gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Method signature: IEntityAuditQuery&amp;lt;T&amp;gt; ForEntitiesAtRevision&amp;lt;T&amp;gt;(long revision)&lt;/p&gt;  &lt;p&gt;The query built using this method will ultimately return to us an IEnumerable&amp;lt;T&amp;gt; (or a single instance of T, or the result of a projection), the enumeration will contains all the instances of the specified type of entity at the requested revision; one or more filtering conditions can be added:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:c76d3f58-a166-4ba8-9844-9efcb88ff6e8" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; "&gt;[Test]
public void ForEntitiesAtRevision()
{
	using (ISession s = _nh.SessionFactory.OpenSession())
	{
		// look for a non existing revision
		using (var tx = s.BeginTransaction())
		{
			IAuditReader auditReader = s.Auditer();
			var rev = auditReader.CreateQuery().ForEntitiesAtRevision&amp;lt;Person&amp;gt;(1).Results();
			Assert.IsNotNull(rev);
			Assert.That(rev.Count() == 2);
			// print the data on the console
			Utils.PrintEntityList(rev);
			tx.Commit();
		}
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;in line 10 I am asking to see all the entities of type Person at their revision number 1, given my test domain this is the result:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:b85ec56d-42d6-457d-a0c9-47c2edffe836" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: plain; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;***** NHibernate.Envers.Tests.Querying.Test2.ForEntitiesAtRevision
System.Linq.Enumerable+WhereSelectListIterator`2[System.Collections.IDictionary,NHibernate.Envers.Tests.Domain.Person] , count: 2
Id: 1, Name: Jhon, Surname: Doe, Note: 
Games:
Id: 1, Name: g0, Type: , Rating: 0, Note: note0
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
---

Id: 2, Name: Jane, Surname: Doe, Note: 
Games:
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
Id: 3, Name: g2, Type: , Rating: 2, Note: note2
---
&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;As you can see I have two entity at that revision number; if I wanted to filter out the results I could have written something similar in line 10:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:c8eb2806-820b-43ec-9919-28989a3ce901" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;var rev = auditReader.CreateQuery().ForEntitiesAtRevision&amp;lt;Person&amp;gt;(1)
.Add(AuditEntity.Property(&amp;quot;Name&amp;quot;).Eq(&amp;quot;Jhon&amp;quot;)).Results();&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ForRevisionsOf&amp;lt;T&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Method signature: IEntityAuditQuery&amp;lt;T&amp;gt; ForRevisionsOf&amp;lt;T&amp;gt;(bool includesDeleted)&lt;/p&gt;

&lt;p&gt;The query built using this method will ultimately return to us an IEnumerable&amp;lt;T&amp;gt; (or a single instance of T, or the result of a projection), the enumeration will contains all the instances of the specified type of entity; one or more filtering conditions can be added.&lt;/p&gt;

&lt;p&gt;If includesDeleted is set to true the revisions where the entities were deleted will be returned (the default value is ‘false’).&lt;/p&gt;

&lt;p&gt;The results of the query will be sorted in ascending order by the revision number, unless an order or projection is added.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:9c2bc20d-4c17-4897-b819-0fd62c97a1d7" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; "&gt;[Test]
public void ForRevisionsOf()
{
	using (ISession s = _nh.SessionFactory.OpenSession())
	{
		// look for a non existing revision
		using (var tx = s.BeginTransaction())
		{
			IAuditReader auditReader = s.Auditer();
			var rev = auditReader.CreateQuery().ForRevisionsOf&amp;lt;Person&amp;gt;(true).Results();
			Assert.IsNotNull(rev);
			Utils.PrintEntityList(rev);
			tx.Commit();
		}
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;This is the ‘messy’ result:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:2ba1528a-08ed-4fbf-9544-017980d92b09" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: plain; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;***** NHibernate.Envers.Tests.Querying.Test2.ForRevisionsOf
System.Linq.Enumerable+WhereSelectListIterator`2[System.Collections.IDictionary,NHibernate.Envers.Tests.Domain.Person] , count: 4
Id: 1, Name: Jhon, Surname: Doe, Note: 
Games:
Id: 1, Name: g0, Type: , Rating: 0, Note: note0
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
---

Id: 2, Name: Jane, Surname: Doe, Note: 
Games:
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
Id: 3, Name: g2, Type: , Rating: 2, Note: note2
---

Id: 2, Name: Jane, Surname: Doe, Note: Modified
Games:
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
Id: 3, Name: g2, Type: , Rating: 2, Note: note2
---

Id: 1, Name: Jhon, Surname: Doe, Note: Modified
Games:
Id: 1, Name: g0, Type: , Rating: 0, Note: note0
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
---
&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;To be honest this function is not so useful without adding some filters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ForHistoryOf&amp;lt;TEntity&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Method signature: IEntityAuditQuery&amp;lt;IRevisionEntityInfo&amp;lt;TEntity, DefaultRevisionEntity&amp;gt;&amp;gt; ForHistoryOf&amp;lt;TEntity&amp;gt;(bool includesDeleted)&lt;/p&gt;

&lt;p&gt;The query built using this method will ultimately return to us an IEnumerable&amp;lt;IRevisionEntityInfo&amp;lt;TEntity, DefaultRevisionEntity&amp;gt;&amp;gt; (or a single instance of IRevisionEntityInfo&amp;lt;TEntity, DefaultRevisionEntity&amp;gt;, or the result of a projection), the enumeration will contains all the revision information of the instances of the specified type of entity; one or more filtering conditions can be added.&lt;/p&gt;

&lt;p&gt;If includesDeleted is set to true the revisions where the entities were deleted will be returned (the default value is ‘false’).&lt;/p&gt;

&lt;p&gt;The results of the query will be sorted in ascending order by the revision number, unless an order or projection is added.&lt;/p&gt;

&lt;p&gt;This function is extremely useful because you can obtain detailed information about the revision number, the timestamp and the kind of operation (added, modified, deleted) alongside with the snapshot of the entity itself; all these information are available through an implementation of the IRevisionEntityInfo&amp;lt;TEntity, TRevisionEntity&amp;gt; interface.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:adfb57fe-5e17-434f-bc6d-1b13ff72fa44" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: csharp; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; "&gt;[Test]
public void ForHistoryOf()
{
	using (ISession s = _nh.SessionFactory.OpenSession())
	{
		// look for a non existing revision
		using (var tx = s.BeginTransaction())
		{
			IAuditReader auditReader = s.Auditer();
			var rev = auditReader.CreateQuery().ForHistoryOf&amp;lt;Person&amp;gt;(true).Results();
			Assert.IsNotNull(rev);
			Utils.PrintRevisionInfoList(rev);
			tx.Commit();
		}
	}
}&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;And here’s the results I get with my domain:&lt;/p&gt;

&lt;p&gt;
  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:fe13d9c1-e848-482b-833f-92b808254f04" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: plain; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;***** NHibernate.Envers.Tests.Querying.Test2.ForHistoryOf
System.Linq.Enumerable+&amp;lt;CastIterator&amp;gt;d__aa`1[NHibernate.Envers.Query.IRevisionEntityInfo`2[NHibernate.Envers.Tests.Domain.Person,NHibernate.Envers.DefaultRevisionEntity]] , count: 4
Rev=1 Timestamp=2011-07-13T14:19:32.1470000 Op=Added
Id: 1, Name: Jhon, Surname: Doe, Note: 
Games:
Id: 1, Name: g0, Type: , Rating: 0, Note: note0
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
---

Rev=1 Timestamp=2011-07-13T14:19:32.1470000 Op=Added
Id: 2, Name: Jane, Surname: Doe, Note: 
Games:
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
Id: 3, Name: g2, Type: , Rating: 2, Note: note2
---

Rev=2 Timestamp=2011-07-13T14:19:32.1630000 Op=Modified
Id: 2, Name: Jane, Surname: Doe, Note: Modified
Games:
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
Id: 3, Name: g2, Type: , Rating: 2, Note: note2
---

Rev=2 Timestamp=2011-07-13T14:19:32.1630000 Op=Modified
Id: 1, Name: Jhon, Surname: Doe, Note: Modified
Games:
Id: 1, Name: g0, Type: , Rating: 0, Note: note0
Id: 2, Name: g1, Type: , Rating: 1, Note: note1
---
&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;/p&gt;

&lt;p&gt;With this post we have covered pretty much all the basic functionalities that NHibernate.Envers offers us to query the revision database tables, take a look at the new examples in the test solution if you want to see it in action live:&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:d335d5e2-b3b7-46ad-b3e0-1ede4bec1403" class="wlWriterEditableSmartContent"&gt;&lt;p&gt;&lt;div&gt;&lt;a href="http://www.primordialcode.com/UserFiles/Guardian/NHibernateTestsEnvers3.zip" target="_self"&gt;NHibernateTestsEnvers3.zip&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;&lt;/div&gt;

&lt;p&gt;Cya next.&lt;/p&gt;&lt;h2&gt;Related Content&lt;/h2&gt;&lt;ul&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-envers-quick-introduction"&gt;NHibernate.Envers - a quick introduction&lt;/a&gt; (6/7/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-envers-querying-part-1"&gt;NHibernate.Envers - Querying - part 1&lt;/a&gt; (6/10/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-envers-customize-revision-entity"&gt;NHibernate.Envers - Customize the Revision Entity&lt;/a&gt; (8/5/2011)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="/Blog/Related/nhibernate-envers-querying-part-2"&gt;&lt;strong&gt;More related document (1)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=N3M1C_9qfFQ:iMgd82xTL5M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=N3M1C_9qfFQ:iMgd82xTL5M:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=N3M1C_9qfFQ:iMgd82xTL5M:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=N3M1C_9qfFQ:iMgd82xTL5M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=N3M1C_9qfFQ:iMgd82xTL5M:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=N3M1C_9qfFQ:iMgd82xTL5M:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=N3M1C_9qfFQ:iMgd82xTL5M:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=N3M1C_9qfFQ:iMgd82xTL5M:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=N3M1C_9qfFQ:iMgd82xTL5M:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/N3M1C_9qfFQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/N3M1C_9qfFQ/nhibernate-envers-querying-part-2</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/nhibernate-envers-querying-part-2#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/nhibernate-envers-querying-part-2</guid><pubDate>Wed, 13 Jul 2011 22:08:30 GMT</pubDate><category>Nhibernate.Envers</category><category>Query</category><feedburner:origLink>http://www.primordialcode.com/blog/post/nhibernate-envers-querying-part-2</feedburner:origLink></item><item><title>Linq to NHibernate - String.Equals with StringComparison option</title><description>&lt;p&gt;
	A couple of days ago &lt;a href="http://blogs.ugidotnet.org/matteomigliore/Default.aspx"&gt;Matteo Migliore&lt;/a&gt; asked me a question about why String.Equals(string, StringComparison) was not supported in Linq to &lt;a href="http://nhforge.org/"&gt;NHibernate&lt;/a&gt; while it was in Entity Framework.&lt;/p&gt;
&lt;p&gt;
	My first answer was that the Linq to NHibernate implementation might have some missing and, if it was not supported, we can extend the provider to add support for missing functions if we know how to translate them in SQL (I even wrote a couple of blog posts in the past about how to extend the provider to add functions to it: &lt;a href="http://www.primordialcode.com/blog/post/nhibernate-3-extending-linq-provider-fix-notsupportedexception"&gt;NHibernate 3 - Extending the Linq Provider to fix some System.NotSupportedException&lt;/a&gt; and &lt;a href="http://www.primordialcode.com/blog/post/nhibernate-customize-linq-provider-user-defined-sql-functions"&gt;NHibernate - Customize the Linq provider to call your user defined SQL functions&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;
	With those things in mind we have all the tools to cover the gaps and implement what we need; basically we want to &amp;lsquo;force&amp;rsquo; a case insensitive string comparison at database level using something like this:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:670923b9-b965-42ac-9f25-49a656c4dbec" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"&gt;
	&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;var res = Session.Query&lt;table1&gt;().Where(t =&amp;gt; t.T1.Equals(&amp;quot;test&amp;quot;, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();&lt;/table1&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;
	I&amp;rsquo;m not a true SQL expert, but when it comes to string comparison a lot of database stuff kicks in (like collations and such) and every database can have a different default behavior to compare strings (by default it should be case insensitive, but I&amp;rsquo;m not really sure of this...so DBA experts can say their own here); aside of that, I think that the default behavior ORMs have is to rely on what the database does.&lt;/p&gt;
&lt;p&gt;
	Matteo confirmed this last statement looking at the SQL expression that Entity Framework 4 generated for his test domain when calling Equals passing in an xxxIgnoreCase StringComparison, in both case (with and without the parameter) EF4 generated this SQL statement:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:cecbed6a-d196-42f5-afe1-e391a0ad819b" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"&gt;
	&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;SELECT 
[Extent1].[Id] AS [Id], 
[Extent1].[FirstName] AS [FirstName], 
[Extent1].[LastName] AS [LastName]
FROM [dbo].[Customers] AS [Extent1]
WHERE N&amp;#39;temp&amp;#39; = [Extent1].[FirstName]&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;
	As you can see this is totally dependent on the database and it can ignore our will to perform a case insensitive equals (due to the database collation for example)...so it&amp;rsquo;s not a &amp;lsquo;perfect&amp;rsquo; translation of what the user wanted to do and it may introduce subtle bugs in your code.&lt;/p&gt;
&lt;p&gt;
	Linq to NHibernate raises us a &amp;lsquo;warning&amp;rsquo; saying that this kind of operation is not supported (intentionally or not...we&amp;rsquo;ll never know...), so the first step is to extend the provider to support this kinds of equals:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:b6cd5a70-2101-4a9b-8204-75a23e01b286" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"&gt;
	&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;public class EqualsStringGenerator : BaseHqlGeneratorForMethod
{
	public EqualsStringGenerator()
	{
		SupportedMethods = new[]
		                   	{
		                   		ReflectionHelper.GetMethodDefinition&lt;string&gt;(x =&amp;gt; x.Equals(null, StringComparison.CurrentCulture))
		                   	};
	}

	public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection&lt;expression&gt; arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
	{
		return treeBuilder.Equality(
			visitor.Visit(targetObject).AsExpression(),
			visitor.Visit(arguments[0]).AsExpression());
	}
}

public class ExtendedLinqtoHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry
{
	public ExtendedLinqtoHqlGeneratorsRegistry()
	{
		this.Merge(new EqualsStringGenerator());
	}
}&lt;/expression&gt;&lt;/string&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;
	You can read my previous articles for the details, however the important thing here is that we are adding a new supported method (the overloaded version of String.Equals) and how we translate it to SQL in the BuildHql() function: we are basically ignoring the second parameter - the StringComparison - and we are constructing a normal Equality between two operands.&lt;/p&gt;
&lt;p&gt;
	This extension makes Linq to NHibernate operate exactly as EF4 does and will generate a similar kind of SQL query (it completely relies on the database for the case sensitivity or not of the operation).&lt;/p&gt;
&lt;p&gt;
	But we can do the things a little bit better and add support for forcing a case insensitive equals even if case sensitive collations are used for your database, making Linq-To-NHibenrate a little bit smarter. The trick is simple: add a SQL LOWER() call to both the sides of the equality operator:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:b28e7886-024b-4361-bdad-a0b4c0b6c16f" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"&gt;
	&lt;pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;public class EqualsStringGenerator : BaseHqlGeneratorForMethod
{
	public EqualsStringGenerator()
	{
		SupportedMethods = new[]
		                   	{
		                   		ReflectionHelper.GetMethodDefinition&lt;string&gt;(x =&amp;gt; x.Equals(null, StringComparison.CurrentCulture))
		                   	};
	}

	public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection&lt;expression&gt; arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
	{
		StringComparison comparison = (StringComparison)(arguments[1].As&lt;constantexpression&gt;().Value);
		if (comparison == StringComparison.CurrentCultureIgnoreCase ||
		    comparison == StringComparison.InvariantCultureIgnoreCase ||
		    comparison == StringComparison.OrdinalIgnoreCase)
		{
			return treeBuilder.Equality(
				treeBuilder.MethodCall(&amp;quot;lower&amp;quot;, new[] { visitor.Visit(targetObject).AsExpression() }),
				treeBuilder.MethodCall(&amp;quot;lower&amp;quot;, new[] { visitor.Visit(arguments[0]).AsExpression() }));
		}
		return treeBuilder.Equality(
			visitor.Visit(targetObject).AsExpression(),
			visitor.Visit(arguments[0]).AsExpression());
	}
}&lt;/constantexpression&gt;&lt;/expression&gt;&lt;/string&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;
	Using the treeBuilder.MethodCall(&amp;ldquo;lower&amp;rdquo;, ...) we are adding the desired call, the good thing is that this will be database independent (as long as your database support this function, otherwise you can extend the NHibernate dialect for your database and add support for it); this is what NHibernate now generates for my test domain:&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:65cd6aa9-e31c-412b-a37f-c43642fc2326" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"&gt;
	&lt;pre class="brush: sql; gutter: false; first-line: 1; tab-size: 4;  toolbar: true; "&gt;NHibernate: select TOP (@p0)  table1x0_.ID as ID7_, table1x0_.T1 as T2_7_, table1x0_.T2 as T3_7_, table1x0_.GuidTest as GuidTest7_, table1x0_.Tb2 as Tb5_7_, table1x0_.Tb3 as Tb6_7_ from TABLE1 table1x0_ where lower(table1x0_.T1)=lower(@p1);@p0 = 1 [Type: Int32 (0)], @p1 = &amp;#39;test&amp;#39; [Type: String (4000)]&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;
	This is far from being an optimized solution and we are not translating correctly all the behaviors of this overloaded version of the string comparison, nonetheless is a good starting point for it.&lt;/p&gt;
&lt;p&gt;
	How to force then a case sensitive string comparison ? One thing that comes into my mind is to extend the provider once again and to cast both the operands to a binary type, in this way the comparison will be over array of bytes and it will be &amp;lsquo;sensitive&amp;rsquo; by default...but I&amp;rsquo;ll leave this to you &lt;img alt="Open-mouthed smile" class="wlEmoticon wlEmoticon-openmouthedsmile" src="http://www.primordialcode.com/UserFiles/Guardian/wlEmoticon-openmouthedsmile_2_7.png" style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" /&gt;.&lt;/p&gt;
&lt;h2&gt;Related Content&lt;/h2&gt;&lt;ul&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-customize-linq-provider-user-defined-sql-functions"&gt;NHibernate - Customize the Linq provider to call your user defined SQL functions&lt;/a&gt; (10/1/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-linq-dynamic-filtering-lambda-expressions"&gt;NHibernate Linq provider: dynamic filtering using lambda expressions&lt;/a&gt; (10/20/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/nhibernate-3-extending-linq-provider-fix-notsupportedexception"&gt;NHibernate 3 - Extending the Linq Provider to fix some System.NotSupportedException&lt;/a&gt; (8/13/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/linq-nhibernate-query-property-setter"&gt;Linq to NHibernate: how to query on a property without setter&lt;/a&gt; (12/22/2009)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="http://www.primordialcode.com/blog/post/breaking-news-european-nhibernate-day-officially-announced"&gt;Breaking news: the First European NHibernate Day had been officially announced&lt;/a&gt; (5/20/2010)&lt;/li&gt;&lt;li style="list-style-type: none"&gt;&lt;a href="/Blog/Related/linq-to-nhibernate-string.equals-with-stringcomparison-option"&gt;&lt;strong&gt;More related document (21)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=PRjGh9KoFsE:QQrbg3fQYdk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=PRjGh9KoFsE:QQrbg3fQYdk:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=PRjGh9KoFsE:QQrbg3fQYdk:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=PRjGh9KoFsE:QQrbg3fQYdk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=PRjGh9KoFsE:QQrbg3fQYdk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=PRjGh9KoFsE:QQrbg3fQYdk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=PRjGh9KoFsE:QQrbg3fQYdk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?i=PRjGh9KoFsE:QQrbg3fQYdk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/PrimordialCode?a=PRjGh9KoFsE:QQrbg3fQYdk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/PrimordialCode?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/PrimordialCode/~4/PRjGh9KoFsE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/PrimordialCode/~3/PRjGh9KoFsE/linq-to-nhibernate-string.equals-with-stringcomparison-option</link><author>Guardian</author><comments>http://www.primordialcode.com/blog/post/linq-to-nhibernate-string.equals-with-stringcomparison-option#feedback</comments><guid isPermaLink="false">http://www.primordialcode.com/blog/post/linq-to-nhibernate-string.equals-with-stringcomparison-option</guid><pubDate>Tue, 14 Jun 2011 17:55:17 GMT</pubDate><category>Nhibernate</category><category>Linq</category><category>Equals</category><feedburner:origLink>http://www.primordialcode.com/blog/post/linq-to-nhibernate-string.equals-with-stringcomparison-option</feedburner:origLink></item></channel></rss>

