<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" gd:etag="W/&quot;DEEASXc8eyp7ImA9WhBQE0k.&quot;"><id>tag:blogger.com,1999:blog-31061699</id><updated>2013-03-15T13:24:08.973+02:00</updated><title>Stephan Zahariev's Blog</title><subtitle type="html">Keen on .NET Framework, Delphi, DataStage, SQL Server, Teradata.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/StephanZaharievBlog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="stephanzaharievblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">StephanZaharievBlog</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;AkQGRHwzfSp7ImA9WhNQF0s.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-7470725643245600088</id><published>2012-11-24T16:45:00.001+02:00</published><updated>2012-11-24T16:45:25.285+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-24T16:45:25.285+02:00</app:edited><title>Exporting/Importing Microsoft Outlook 2010 Email Account</title><content type="html">&lt;p&gt;Microsoft Outlook 2010 is pretty sophisticated application but unfortunately just recently I was hit by a major imperfection – there is no way to import/export your email account settings (IMAP/POP3 configuration, etc.). Nevertheless there is one tricky way to do it – import/export some Windows registry keys. To export the account settings just export the following key:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To do so just run &lt;em&gt;regedit.exe&lt;/em&gt; and navigate to the key above, right click on it and select &lt;em&gt;Export&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;The import process will be to simply double click on the exported file.&lt;/p&gt;  </content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/7470725643245600088/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=7470725643245600088" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7470725643245600088?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7470725643245600088?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2012/11/exportingimporting-microsoft-outlook.html" title="Exporting/Importing Microsoft Outlook 2010 Email Account" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DE8FSXozfCp7ImA9WhJVE00.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-1550711912960159369</id><published>2012-08-30T00:42:00.001+03:00</published><updated>2012-08-30T09:06:58.484+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-30T09:06:58.484+03:00</app:edited><title>Getting Started with IBM Netezza</title><content type="html">&lt;p&gt;Data Warehouse, Business Intelligence, ETL, Data Analysis are terms we here more and more every day. But there is one name that becomes more and more popular: &lt;a href="http://www-01.ibm.com/software/data/netezza/"&gt;Netezza&lt;/a&gt; – state of the art data warehouse appliance offered by IBM. If you want to get started with Netezza, there is a good news: IBM distributes an emulator running under Windows that you can download and deploy at home. So here is what you need:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Download and install &lt;a href="http://www.vmware.com/products/player/"&gt;VMware player&lt;/a&gt; (free) or VMware workstation (paid)  &lt;li&gt;Install &lt;a href="http://www.vmware.com/support/developer/vix-api/index.html"&gt;VIX API&lt;/a&gt; (free) if using VMware player  &lt;li&gt;Download the Netezza emulator by first requesting to join the IBM Netezza Developer Network (NDN) by following this link: &lt;a href="https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=35ac05e2-4e00-42fe-b252-111e5f3ad8fa"&gt;https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=35ac05e2-4e00-42fe-b252-111e5f3ad8fa&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;When you join the IBM NDN you will find there not only the emulator but also the required product documentation that will guide you to master the product. Here is what you will get when the emulator is running:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-S19AZNxSX6I/UD6Muavz35I/AAAAAAAAIyQ/nsjL8rAaz7c/s1600-h/image4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-zCFbJG64lks/UD6Mu_oV-HI/AAAAAAAAIyY/oN_2B09D-5g/image_thumb2.png?imgmax=800" width="360" height="353"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Currently IBM does not offer Windows based GUI for querying the Netezza so you will have to connect to the Netezza host and use &lt;strong&gt;nzsql&lt;/strong&gt; by using &lt;a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/"&gt;ssh client&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;One 3rd party alternative to the nzsql is the &lt;a href="http://www.aginity.com/ProductivityTools/WorkbenchOverview.aspx"&gt;Aginity Workbench for Netezza&lt;/a&gt;. It runs under Windows and provides GUI for querying the Netezza. The application will require a free registration after a 10 days trial period. The downside is that you will need a Netezza ODBC or OLE DB driver to connect to the Netezza host. Unfortunately these drivers can be downloaded only by IBM customers.&lt;/p&gt;  </content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/1550711912960159369/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=1550711912960159369" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/1550711912960159369?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/1550711912960159369?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2012/08/getting-started-with-ibm-netezza.html" title="Getting Started with IBM Netezza" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-zCFbJG64lks/UD6Mu_oV-HI/AAAAAAAAIyY/oN_2B09D-5g/s72-c/image_thumb2.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUYHQ3g4fip7ImA9WhJVEko.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-7005451608228810308</id><published>2012-08-29T23:45:00.001+03:00</published><updated>2012-08-29T23:45:32.636+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-29T23:45:32.636+03:00</app:edited><title>Using Notepad++ to Search and Replace using Regular Expressions</title><content type="html">&lt;p&gt;Not long time ago I had to modify a 300 lines SQL Server stored procedure that uses columns containing spaces in the names into a version that does not contain spaces. For example columns like &lt;em&gt;&lt;strong&gt;[Price Rate]&lt;/strong&gt;&lt;/em&gt; should be converted to &lt;em&gt;&lt;strong&gt;Price_Rate&lt;/strong&gt;&lt;/em&gt;. Doing this manually is long and tedious task. Fortunately Notepad++ saved the day once again – use &lt;a href="http://en.wikipedia.org/wiki/Regular_expression"&gt;regular expressions&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;To to search and replace the spaces for the column names with underscore open the Notepad++ &lt;strong&gt;Replace&lt;/strong&gt; dialog (Ctrl+H) and type the following for the search pattern:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;\[([0-9a-zA-Z]*) ([0-9a-zA-Z]*)\]&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The above will match everything that starts with [ continues with combination of letters or numbers, has a space after that, has a combination of letter or number after the space and ends with ]&lt;/p&gt; &lt;p&gt;Type the following for the “&lt;strong&gt;Replace with&lt;/strong&gt;” field:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;\1_\2&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This means that Notepad++ will replace the &lt;strong&gt;\1&lt;/strong&gt; with the match between the [ and the space from the column name. The &lt;strong&gt;\2&lt;/strong&gt; will be replaced with the match between the space and the ]. Here we are using one special feature – if part of regular expression is within a round brackets then this match can be tagged using \1, \2, \3, etc.&lt;/p&gt; &lt;p&gt;At the end select “&lt;strong&gt;Regular expression&lt;/strong&gt;” for “&lt;strong&gt;Search Mode&lt;/strong&gt;” and hit the “&lt;strong&gt;Replace All&lt;/strong&gt;” button.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-yMEHPM6jtfo/UD5_adt7Z_I/AAAAAAAAIx4/9LyOgekfhd4/s1600-h/image%25255B9%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-4Cva6EM90jM/UD5_a5aD9FI/AAAAAAAAIyA/k02z16iUTzQ/image_thumb%25255B5%25255D.png?imgmax=800" width="498" height="307"&gt;&lt;/a&gt;&lt;/p&gt;   &lt;p&gt;For more information about the special character of a regular expressions take a look &lt;a href="http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_Expressions"&gt;here&lt;/a&gt;.&lt;/p&gt;  </content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/7005451608228810308/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=7005451608228810308" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7005451608228810308?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7005451608228810308?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2012/08/using-notepad-to-search-and-replace.html" title="Using Notepad++ to Search and Replace using Regular Expressions" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-4Cva6EM90jM/UD5_a5aD9FI/AAAAAAAAIyA/k02z16iUTzQ/s72-c/image_thumb%25255B5%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUYGQH06eCp7ImA9WhRaEEs.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-6474587051394420624</id><published>2012-02-12T18:12:00.001+02:00</published><updated>2012-02-12T18:12:01.310+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-12T18:12:01.310+02:00</app:edited><title>Introduction to DSCop</title><content type="html">&lt;p&gt;&lt;a href="http://dscop.codeplex.com/" target="_blank"&gt;DSCop&lt;/a&gt; is an open source tool that analyzes IBM InfoSphere &lt;a href="http://www-01.ibm.com/software/data/infosphere/datastage/" target="_blank"&gt;DataStage&lt;/a&gt; jobs and reports information such as violation of some commonly accepted best practices. It's developed in C# and provides plugin based architecture to allow 3rd party extensibility. The tool comes with a few sample plugins that should be enough for basic understanding how the tool works and how to implement your own plugins. &lt;/p&gt; &lt;h4&gt;Requirements&lt;/h4&gt; &lt;p&gt;Computer running version of Microsoft Windows with .NET Framework 4 preinstalled.&lt;/p&gt; &lt;h4&gt;Download and Install&lt;/h4&gt; &lt;p&gt;The current publicly available version of &lt;a href="http://dscop.codeplex.com/" target="_blank"&gt;DSCop&lt;/a&gt; is &lt;a href="http://dscop.codeplex.com/releases/view/82152" target="_blank"&gt;RC1&lt;/a&gt; available &lt;a href="http://dscop.codeplex.com/releases/view/82152" target="_blank"&gt;here&lt;/a&gt;. After download unzip the file and you are ready to use the tool.&lt;/p&gt; &lt;h4&gt;Basic Usage Scenario&lt;/h4&gt; &lt;p&gt;The tool will automatically search the folder where the DSCop.exe file is located and will load all the plugins. Each plugin contains one or more rules. Each rule enforces certain check that is performed on&amp;nbsp; a DataStage job. The jobs should be exported to one or many xml files.&lt;/p&gt; &lt;p&gt;To check a job with the tool, use this syntax:&lt;/p&gt; &lt;p&gt;&lt;em&gt;DSCop jobfilename.xml&lt;/em&gt;&lt;/p&gt; &lt;p&gt;As a result you will get a list with rules that were executed, jobs processed, rule violations found.&lt;/p&gt; &lt;p&gt;A sample output after running the tool is shown here:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-EE0yw1aSm0o/TzfkusBcnqI/AAAAAAAAIs4/gjJA-K821qw/s1600-h/image%25255B2%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-XkPXa-kbovo/Tzfkvrq62zI/AAAAAAAAItA/FpzVrCuyKZ8/image_thumb.png?imgmax=800" width="244" height="125"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;DataStage has the ability to export multiple jobs into singe XML file. However if your jobs are not in one file you can use wildcards to specify them like this:&lt;/p&gt; &lt;p&gt;&lt;em&gt;DSCop Staging*.xml&lt;/em&gt;&lt;/p&gt; &lt;h4&gt;Advanced Usage Scenario&lt;/h4&gt; &lt;p&gt;Now we are going to explore some of the advanced use cases where you want to run the tool by including/excluding certain rules.&lt;/p&gt; &lt;p&gt;The syntax for running the tool by explicitly enumerating the rules you want to execute is:&lt;/p&gt; &lt;p&gt;&lt;em&gt;DSCop jobfile.xml –include RuleName1 RuleName2 RuleName3&lt;/em&gt;&lt;/p&gt; &lt;p&gt;A sample output using this syntax is shown bellow: &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-OjLkB9HGmYM/TzfkwenDgII/AAAAAAAAItI/AgBTG0zSdqE/s1600-h/image%25255B8%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-svDzuxTA_fs/Tzfkxs4EmqI/AAAAAAAAItQ/LrdVrFz0akY/image_thumb%25255B2%25255D.png?imgmax=800" width="244" height="125"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Please notice the “*Ignore” next to the rules that are not enforced.&lt;/p&gt; &lt;p&gt;To exclude certain rules use the following syntax:&lt;/p&gt; &lt;p&gt;&lt;em&gt;DSCop jobfile.xml –exclude RileName1, RuleName2, RuleName3&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-7x4F47gxTrU/TzfkyxK6yLI/AAAAAAAAItY/C7EKBdU7Jqg/s1600-h/image%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-j6DhjfP2O0Q/TzfkzwfQXkI/AAAAAAAAItg/cA3aPds7hSA/image_thumb%25255B1%25255D.png?imgmax=800" width="244" height="125"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4&gt;Sample Plugins&lt;/h4&gt; &lt;p&gt;The &lt;a href="http://dscop.codeplex.com/releases/view/82152" target="_blank"&gt;RC1&lt;/a&gt; version of the tool comes with the following plugins/rules:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;CoreRules/StableSortRule&lt;/strong&gt; – checks all Sort stages whether the &lt;em&gt;StableSort=true&lt;/em&gt;. &lt;em&gt;StableSort&lt;/em&gt; is enabled by default but should not be used due to decreased performance.  &lt;li&gt;&lt;strong&gt;CoreRules/TeradataConnectorParametersRule&lt;/strong&gt; – checks all Teradata connector stages whether the &lt;em&gt;ServerName/Username/Password&lt;/em&gt; properties are parameterized. Hardcoding this information should be avoided.  &lt;li&gt;&lt;strong&gt;NamingRules/PrefixNamingRule&lt;/strong&gt; – checks if stage names are following predefined naming convention. The naming convention is described in a the file &lt;em&gt;NamingPrefixes.xml&lt;/em&gt; located in the same folder as the plugin.&lt;/li&gt;&lt;/ul&gt; &lt;h4&gt;Feedback&lt;/h4&gt; &lt;p&gt;You can send your feedback to the following email: dscoptool-at-gmail.com&lt;/p&gt;  </content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/6474587051394420624/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=6474587051394420624" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/6474587051394420624?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/6474587051394420624?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2012/02/introduction-to-dscop.html" title="Introduction to DSCop" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-XkPXa-kbovo/Tzfkvrq62zI/AAAAAAAAItA/FpzVrCuyKZ8/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;D08NSX8ycCp7ImA9WhVVFE8.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-4517739361259735094</id><published>2012-02-10T17:21:00.001+02:00</published><updated>2012-05-08T00:24:58.198+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-08T00:24:58.198+03:00</app:edited><title>Some tips for the SSD owners running Windows</title><content type="html">&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Solid-state_drive"&gt;Solid State Drives (SSD)&lt;/a&gt; are much different than &lt;a href="http://en.wikipedia.org/wiki/Hard_disk_drive"&gt;Hard Disk Drives (HDD)&lt;/a&gt;. Because of this you must change your usual pattern of usage. Otherwise you risk your shiny new SSD to be at the end of its life only after a few months of use. In this post I will describe some of the tricks that seems to work on my machine.&lt;/p&gt; &lt;p&gt;The main disadvantage of the SSD devices is that each data cell can be re-written limited number of times. This number is several times lower than the data cell in the HDD. So you must make sure that the applications you are using are not constantly writing on the SSD. Bellow is a short list that will extend the life of your SSD.&lt;/p&gt; &lt;h3&gt;Must Have&lt;/h3&gt; &lt;h3&gt;&amp;nbsp;&lt;/h3&gt; &lt;h4&gt;Disable Windows Swap File&lt;/h4&gt; &lt;p&gt;If Windows runs out of RAM then it moves some of the data to the swap file on your disk drive. This is one of the primary sources of disk write operations on systems running with low RAM memory. Buy more RAM and &lt;a href="http://www.youtube.com/watch?v=XM1UZc9AkE4" target="_blank"&gt;disable Windows swap file&lt;/a&gt;. The RAM you need depends on the applications you are running and the version of Windows. IMHO for Windows 7 you need at least 4GB RAM, 8GB is recommended.&lt;/p&gt; &lt;h4&gt;Turn off Disk Defragmenter Schedule&lt;/h4&gt; &lt;p&gt;The classic hard disk drives are using a moving head that reads the data from the disk. If the file is not located on sequential blocks on the disk, the head positioning time will increase and this will slow down the read process. The defragmentation process makes sure that the file blocks are located in a sequence on the disk. The SSD do not suffer from this since there is no head that reads the information. So you don’t need this feature.&lt;/p&gt; &lt;p&gt;If you perform defragmentation on SSD drive this will only drain write cycles from its life.&lt;/p&gt; &lt;p&gt;Windows 7 automatically detects SSD drives and turns of the defragmentation but it does not hurt to check if it has been stopped. On Windows 7 you can disable the Disk Defragmenter Schedule like &lt;a href="http://www.sevenforums.com/tutorials/3292-disk-defragmenter-schedule-turn-off.html" target="_blank"&gt;this&lt;/a&gt;.&lt;/p&gt; &lt;h4&gt;Move Temp Folders to RAM Drive&lt;/h4&gt; &lt;p&gt;RAM drive is a disk drive that looks looks like a normal drive for your windows but stores the information in the RAM instead of using a SSD or HDD. The operations with RAM drive are several times faster than the operations with SSD or HDD. The downside is that you lose the drive content after powering off your computer. But the Temp folder is used by Windows to store temporary files not needed after power off. So you don’t have to worry that you will lose something important.&lt;/p&gt; &lt;p&gt;Moving the windows Temp folder to a RAM drive will decrease the write operations on your SSD and this prolongs its life. &lt;a href="http://answers.microsoft.com/en-us/windows/forum/windows_7-files/change-location-of-temp-files-folder-to-another/19f13330-dde1-404c-aa27-a76c0b450818" target="_blank"&gt;Here&lt;/a&gt; is how to move the Windows Temp folder to another location. The only think you should select is the software that emulates your RAM drive since Windows still does not have such a feature. For example the &lt;a href="http://ramdisk.tekcities.com/RAMDisk/ramdriv.htm"&gt;QSoft’s RAMDisk&lt;/a&gt; does a perfect job for me. You can download a free version that will expire after 6 months (at which point you need to download new free version which will be active for another 6 months).&lt;/p&gt; &lt;p&gt;You can even move the location of Internet Temp folder but this will slow down your browsing since there will be no cached images or pages and everything will be downloaded again after you power off the PC.&lt;/p&gt; &lt;h4&gt;Turn off Windows Search&lt;/h4&gt; &lt;p&gt;Windows Search is another feature that generates a lot of write operations due to the indexing process. The SSD are quite fast on reading data so you don’t need indexes to speed up your search. You can turn it off like &lt;a href="http://www.addictivetips.com/windows-tips/disable-search-indexing-in-windows-7/" target="_blank"&gt;this&lt;/a&gt; on Windows 7 systems. Of course if you are not satisfied you can always turn it on.&lt;/p&gt; &lt;h4&gt;Monitor the Overall Health of the Drive&lt;/h4&gt; &lt;p&gt;Install an application that will report your drive health. For example a good choice is the free version of &lt;a href="http://ssd-life.com"&gt;SSDLife&lt;/a&gt;. It can be downloaded &lt;a href="http://ssd-life.com/SSDLifeFree.exe"&gt;here&lt;/a&gt;. The most useful metric is the approximate date when the drive is supposed to failure.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-cs3FWvV5Xd0/TzU1_9yE-PI/AAAAAAAAIso/h-_O21xSobY/s1600-h/image2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-1trsaD2oIlE/TzU2AtBxTZI/AAAAAAAAIsw/FAWfZlLwvZs/image_thumb.png?imgmax=800" width="188" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&amp;nbsp;&lt;/h3&gt; &lt;h3&gt;Nice To Have&lt;/h3&gt; &lt;h3&gt;&amp;nbsp;&lt;/h3&gt; &lt;h4&gt;Hibernation&lt;/h4&gt; &lt;p&gt;Hibernation becomes very tempting when combined with fast disk drive. The down side is that this feature stores GB of information (depending on you RAM size) every time when the system is hibernated. Having in mind that the SSD drives are sensible to the number of writes it may quickly drain the life from your new SSD drive. And of course after disabling you get some more free space on your drive. &lt;a href="http://www.sevenforums.com/tutorials/819-hibernate-enable-disable.html" target="_blank"&gt;Here&lt;/a&gt; is how to do it on Windows 7.&lt;/p&gt; &lt;h4&gt;Disable System Restore&lt;/h4&gt; &lt;p&gt;System Restore is helpful if you mess up your system – for example installing wrong device driver. However, this feature consumes significant amount of free space on your SSD drive. If you are suffering from free space problems and you are confident that changes you make to your system are safe you can &lt;a href="http://www.howtogeek.com/howto/3187/disable-system-restore-in-windows-7/"&gt;disable System Restore&lt;/a&gt;.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/4517739361259735094/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=4517739361259735094" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/4517739361259735094?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/4517739361259735094?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2012/02/some-tips-for-ssd-owners-running.html" title="Some tips for the SSD owners running Windows" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-1trsaD2oIlE/TzU2AtBxTZI/AAAAAAAAIsw/FAWfZlLwvZs/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0EHSX4yeSp7ImA9WxFRFEg.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-6102991491291686554</id><published>2010-04-28T13:47:00.001+03:00</published><updated>2010-04-28T13:47:18.091+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-04-28T13:47:18.091+03:00</app:edited><title>Migrating ASP.NET MVC 1.0 to MVC 2.0: Real World Scenario</title><content type="html">&lt;p&gt;As most of you have noticed, ASP.NET MVC v.2.0 has been &lt;a href="http://weblogs.asp.net/scottgu/archive/2010/03/11/asp-net-mvc-2-released.aspx"&gt;released&lt;/a&gt; last month. The new version introduces lots of cool features, so most of the existing MVC 1 applications will be upgraded to the new release. In the current post I will try to share my experience with migrating existing ASP.NET MVC 1.0 application to MVC 2.0.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt;: There is an existing ASP.NET MVC 1.0 web application build on top of .NET Framework 3.5, jQuery and Visual Studio 2008. The goal is to migrate the application to MVC 2, while keeping the other libraries and tools (.NET 3.5, VS2008, etc).&lt;/p&gt; &lt;h3&gt;Identifying the breaking changes&lt;/h3&gt; &lt;p&gt;The first step from the process would be to check the ASP.NET MVC 2.0 &lt;a href="http://www.asp.net/learn/whitepapers/what-is-new-in-aspnet-mvc/#_TOC5"&gt;breaking changes&lt;/a&gt;. Naturally after carefully evaluating each item in the breaking changes list, I have find out that the following will be a problem: “&lt;em&gt;JsonResult now responds only to HTTP POST requests&lt;/em&gt;”. The problem was caused by a jQuery plug-in that uses only HTTP GET. So the solution was to:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Replace the plug-in by someone more configurable that can use HTTP POST. You should do it in case that your application exposes sensitive information and is vulnerable to the attack described &lt;a href="http://haacked.com/archive/2009/06/25/json-hijacking.aspx"&gt;here&lt;/a&gt;.  &lt;li&gt;Explicitly allow HTTP GET on JsonResults. You can do it by using the JsonRequestBehavior.AllowGet&lt;/li&gt;&lt;/ul&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;[AcceptVerbs(HttpVerbs.Get)]&lt;br&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; JsonResult GetData()&lt;br&gt;{&lt;br&gt;    &lt;span style="color: #008000"&gt;//Some other code&lt;/span&gt;&lt;br&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Json(data, JsonRequestBehavior.AllowGet);&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;I was lucky that the information exposed in my application was not sensitive, so I decided to use the &lt;em&gt;JsonRequestBehavior.AllowGet&lt;/em&gt;.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Migrating the solution to build against ASP.NET MVC 2.0&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Being confident that I have resolved all breaking changes I had to think about migrating the solution to use the new version of MVC 2.0. If you don’t want to do everything by hand, you should use &lt;a href="http://weblogs.asp.net/leftslipper/archive/2010/03/10/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2-rtm.aspx"&gt;this&lt;/a&gt; tool. The tool is build by one of the &lt;a href="http://www.microsoft.com"&gt;Microsoft&lt;/a&gt; employees and works &lt;strong&gt;GREAT&lt;/strong&gt;. However, I have noticed a few gotchas. The tool insists to backup your project before the conversion. This seems redundant, because usually the source code stays in code repository and if somehow the conversion produces a mess, everything could be restored. After all I had to wait a few extra minutes for the backup (more than 1GB in my case). The second issue that I have found is the update of the jQuery files. The tool updates the jQuery and Microsoft AJAX libraries. Since the web site was relying on several other 3rd party jQuery plug-ins I didn’t want the jQuery upgrade. So I had to manually remove the update. Despite of the above, the tool is absolutely &lt;strong&gt;FANTASTIC&lt;/strong&gt; an you will need it.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Running the application&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Up to now, everything went pretty well and the solution compiled without problems. So I was ready to run it. After hitting F5 I was stunned. The application started to close and open pages by itself! With the help of a few unit tests and Goolge I was able to identify the source of the problem. It turns out that there is another undocumented breaking change: a value from &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.controllerbase.tempdata.aspx"&gt;TempData&lt;/a&gt; dictionary will be removed after the request in which it is read! You can read more &lt;a href="http://blog.donnfelker.com/2010/02/26/aspnet-mvc2-tempdata-now-persists/"&gt;here&lt;/a&gt;. The fix was relatively easy and soon everything was working as usual.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Bottom line&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;The migration process from ASP.NET MVC 1.0 to MVC 2.0 is relatively easy and you should do it. The new features are awesome.&lt;/p&gt;  </content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/6102991491291686554/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=6102991491291686554" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/6102991491291686554?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/6102991491291686554?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2010/04/migrating-aspnet-mvc-10-to-mvc-20-real.html" title="Migrating ASP.NET MVC 1.0 to MVC 2.0: Real World Scenario" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;DEEASXczeCp7ImA9WhBQE0k.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-3857228549661646922</id><published>2010-03-26T01:54:00.003+02:00</published><updated>2013-03-15T13:24:08.980+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-15T13:24:08.980+02:00</app:edited><title>ASP.NET MVC Best Practices – Routes to Ignore</title><content type="html">Routing is a key feature from the &lt;a href="http://www.asp.net/mvc"&gt;ASP.NET MVC&lt;/a&gt;. If you are not familiar with this concept, take a look &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx"&gt;here&lt;/a&gt;, because I’m not going to explain it. I’m going to share some routes that you should ignore in your configuration.&lt;br /&gt;
So maybe you are wondering, why should I ignore some routes? And the simple answer is: Because most of the time, different search engines/crawlers/bots will try to index your site and they will request for specific files. For example, &lt;a href="http://www.google.com/"&gt;Google&lt;/a&gt; will try to access the following file: &lt;a href="http://yoursite.com/robots.txt"&gt;http://yoursite.com/robots.txt&lt;/a&gt;. The &lt;i&gt;robots.txt&lt;/i&gt; file is used to to give instructions about your site to web robots. More info can be found &lt;a href="http://en.wikipedia.org/wiki/Robots_exclusion_standard"&gt;here&lt;/a&gt;. Up to now, everything sounds great, but if your site does not have robots.txt file, the ASP.NET MVC framework will raise an exception upon a request like the above. So your log, where the unhandled exceptions are reported can be flooded with messages like:&lt;br /&gt;
System.Web.HttpException : A public action method 'robots.txt' could not be found&lt;br /&gt;
on controller 'YourPage.Controllers.YourController'.&lt;br /&gt;
Obviously, there are two ways to handle this – provide a dummy robots.txt file or instruct the ASP.NET MVC framework to ignore such URL’s. I prefer the second approach. In this post I will try to summarize all the URL’s that should be ignored by the ASP.NET application. So, here they are:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Robots_exclusion_standard"&gt;~/robots.txt&lt;/a&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Site_map"&gt;~/sitemap&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;~/sitemap.gz&lt;/i&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Sitemaps"&gt;~/sitemap.xml&lt;/a&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;&lt;a href="http://www.microsystools.com/products/sitemap-generator/faq/xml-sitemaps-compression-gzip/"&gt;~/sitemap.xml.gz&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;~/google_sitemap.xml&lt;/i&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;~/google_sitemap.xml.gz&lt;/i&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Favicon"&gt;~/favicon.ico&lt;/a&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;~/mobile&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;~/iphone&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.webmasterworld.com/html/3560399.htm"&gt;~/apple-touch-icon.png&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;~/sitemap.txt&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;~/sitemap.rss&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://webmasters.stackexchange.com/questions/44257/strange-request-from-bingbot-for-trafficbasedsspsitemap-xml"&gt;~/trafficbasedsspsitemap.xml&lt;/a&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
You need to ignore the routes above, ONLY if your site do not uses such a file. If you are not familiar with the sitemaps concept,&amp;nbsp; &lt;a href="http://www.forestsoftware.co.uk/do-i-need-a-site-map.html"&gt;here&lt;/a&gt; is a quick overview that answers to most of the questions.&lt;br /&gt;
Here is the code, taken from the &lt;a href="http://msdn.microsoft.com/en-us/library/2027ewzw.aspx"&gt;Global.asax.cs&lt;/a&gt; file that should ignore some of the URL’s outlined above:&lt;br /&gt;
&lt;div id="codeSnippetWrapper" style="background-color: #f4f4f4; border: 1px solid silver; cursor: text; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;,courier,monospace; font-size: 8pt; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding: 4px; text-align: left; width: 97.5%;"&gt;
&lt;pre id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;,courier,monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"{resource}.axd/{*pathInfo}"&lt;/span&gt;);

routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"robots.txt"&lt;/span&gt;);
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"sitemap"&lt;/span&gt;);
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"sitemap.gz"&lt;/span&gt;);
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"sitemap.xml"&lt;/span&gt;);
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"sitemap.xml.gz"&lt;/span&gt;);
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"google_sitemap.xml"&lt;/span&gt;);
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"google_sitemap.xml.gz"&lt;/span&gt;);
routes.IgnoreRoute(&lt;span style="color: #006080;"&gt;"favicon.ico"&lt;/span&gt;);

&lt;span style="color: green;"&gt;//Rest of the code is ommited&lt;/span&gt;
}&lt;/pre&gt;
&lt;/div&gt;
I will update the list above as soon as I find a new URL that should be ignored, so stay tuned. As well you are welcome to contribute to this list by posting a comment.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/3857228549661646922/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=3857228549661646922" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/3857228549661646922?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/3857228549661646922?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2010/03/aspnet-mvc-best-practices-routes-to.html" title="ASP.NET MVC Best Practices – Routes to Ignore" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;A04AQHg4eip7ImA9WxBVGUQ.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-8563545483969035021</id><published>2010-02-14T13:04:00.002+02:00</published><updated>2010-02-24T10:25:41.632+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-24T10:25:41.632+02:00</app:edited><title>Some SharePoint 2010 Articles</title><content type="html">&lt;p&gt;Few months ago I have installed the beta version of the SharePoint 2010. The product looks really cool, although some of the requirements like: “must have Windows 2008 64bit” are really annoying.&lt;/p&gt;&lt;p&gt;In the past few weeks I have published some articles in one new site dedicated to SharePoint technologies called &lt;a href="http://www.sharepointmonitor.com/"&gt;SharepointMonitor.com&lt;/a&gt;. If somebody is interested, here is the list:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.sharepointmonitor.com/2010/01/building-approval-workflows-with-sharepoint-server-2010/"&gt;Building Approval Workflows with SharePoint Server 2010&lt;/a&gt; &lt;li&gt;&lt;a href="http://www.sharepointmonitor.com/2010/02/custom-workflows-sharepoint-designer-2010/"&gt;Building Custom Workflows using SharePoint Designer 2010&lt;/a&gt; &lt;li&gt;&lt;a href="http://www.sharepointmonitor.com/2010/01/difference-between-wss-3-0-and-moss-2007/"&gt;Difference between WSS 3.0 and MOSS 2007&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.sharepointmonitor.com/2010/02/getting-started-with-the-sharepoint-2010-excel-services"&gt;Getting Started with the SharePoint 2010 Excel Services&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I have plans for several other articles, so stay tuned. I will update this post when something new comes out.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/8563545483969035021/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=8563545483969035021" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/8563545483969035021?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/8563545483969035021?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2010/02/some-sharepoint-2010-articles.html" title="Some SharePoint 2010 Articles" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0MGQn8-cSp7ImA9WxBVFk0.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-2565575548025617900</id><published>2010-01-17T01:06:00.002+02:00</published><updated>2010-02-19T19:43:43.159+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-19T19:43:43.159+02:00</app:edited><title>NHibernate: Display executed SQL at the bottom of an ASP.NET page (MVC or WebForms)</title><content type="html">&lt;p&gt;Almost every modern application that uses relational database is build on top of &lt;a href="http://en.wikipedia.org/wiki/Object-relational_mapping"&gt;ORM&lt;/a&gt; tool. The ORM tools can significantly decrease the efforts for interacting with the database, but unfortunately most of the developers are not familiar with the SQL code that is produced by the ORM tools. I’m not hiding that my favorite ORM is NHibernate. I’m using it since early beta, but from time to time even I’m surprised by the produced SQL. So, you need to monitor closely what SQL is executed. This blog post will describe one not widely used but very useful approach – the executed SQL will be displayed as a footer on any ASP.NET web page. It does not matter if the web page is using MVC or WebForms. Interested? Then continue reading.&lt;/p&gt;&lt;p&gt;Currently, there are several ways to display the SQL produced by NHibernate:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Database profiler tool – some of the modern RDBMS systems are coming with a profiler tool that can hook to the database engine and display the executed SQL. For example SQL Server comes with &lt;a href="http://msdn.microsoft.com/en-us/library/ms187929.aspx"&gt;SQL Server Profiler&lt;/a&gt;. Unfortunately the SQL Server Express edition is missing this tool. &lt;li&gt;&lt;a href="http://nhprof.com/"&gt;NHibernate Profiler&lt;/a&gt; – this is a third party tool that hooks to your application and monitors the NHibernate. Comes with cool WPF UI interface and lots of other features. Unfortunately at the time of writing you will need to purchase a license to use it. As well you will need to switch from your application to the tool after each action to monitor the produced SQL. &lt;li&gt;&lt;a href="http://logging.apache.org/log4net/index.html"&gt;Log4Net&lt;/a&gt; – you can configure the log4net library to save the produced SQL to a file for example. Unfortunately reading long files with SQL statements is too boring. Sometimes it is tricky to figure out the SQL executed as a result of single action. &lt;li&gt;Display the executed SQL at the bottom of an ASP.NET web page. The idea is to have an IHttpModule module that will inject the SQL code at the end of each request. This approach saves time, because the SQL is visible instantaneously after the action is executed. Unfortunately this trick works only for web applications.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;There are several ways to access the SQL that has been executed by NHibernate. I will use a &lt;a href="https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/manipulatingdata.html#manipulatingdata-interceptors"&gt;NHibernate interceptor&lt;/a&gt;. The code for the interceptor looks like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; NHibernateSQLMonitor : EmptyInterceptor&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Init(Configuration config)&lt;br /&gt;    {&lt;br /&gt;        config.SetInterceptor(&lt;span class="kwrd"&gt;new&lt;/span&gt; NHibernateSQLMonitor());&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; StringBuilder mExecutedSQL = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ExecutedSQL&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; mExecutedSQL.ToString();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ClearExecutedSQL()&lt;br /&gt;    {&lt;br /&gt;        mExecutedSQL = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; NHibernate.SqlCommand.SqlString OnPrepareStatement(&lt;br /&gt;        NHibernate.SqlCommand.SqlString sql)&lt;br /&gt;    {&lt;br /&gt;        mExecutedSQL.AppendLine(sql.ToString());&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnPrepareStatement(sql);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt&lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The important method is &lt;strong&gt;OnPrepareStatement&lt;/strong&gt;. This method is invoked every time NHibernate executes SQL statement. The &lt;strong&gt;sql&lt;/strong&gt; parameter holds the SQL that will be executed.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Before using it, the interceptor must be registered. One possible way to do it is like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;NHibernate.Cfg.Configuration cfg = &lt;span class="kwrd"&gt;new&lt;/span&gt; NHibernate.Cfg.Configuration();&lt;br /&gt;NHibernateSQLMonitor.Init(cfg);&lt;br /&gt;&lt;br /&gt;ISessionFactory sessionFactory = cfg.BuildSessionFactory();&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt&lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now everything is ready for our IHttpModule that will inject the executed SQL at the bottom of a web page. Here is the implementation:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; NHibernateSQLMonitorModule : IHttpModule&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Init(HttpApplication context)&lt;br /&gt;    {&lt;br /&gt;        context.PostRequestHandlerExecute += &lt;span class="kwrd"&gt;new&lt;/span&gt; EventHandler(&lt;br /&gt;  PostRequestHandlerExecute);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;void&lt;/span&gt; PostRequestHandlerExecute(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        HttpContext httpContext = ((HttpApplication)sender).Context;&lt;br /&gt;        HttpResponse response = httpContext.Response;&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (response.StatusCode == 302)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;//Browser performs redirect. Do nothing.&lt;/span&gt;&lt;br /&gt;            &lt;span class="rem"&gt;//The executed SQL will be shown on the next page&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (response.ContentType == &lt;span class="str"&gt;"text/html"&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            response.Write(&lt;span class="str"&gt;"&amp;lt;hr&amp;gt;"&lt;/span&gt;);&lt;br /&gt;            response.Write(&lt;span class="str"&gt;"&amp;lt;b&amp;gt;SQL Executed by NHibernate&amp;lt;/b&amp;gt;"&lt;/span&gt;);&lt;br /&gt;            response.Write(&lt;span class="str"&gt;"&amp;lt;br&amp;gt;"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;string&lt;/span&gt; executedSQL = NHibernateSQLMonitor.ExecutedSQL.Replace(&lt;br /&gt;   &lt;span class="str"&gt;"\n"&lt;/span&gt;, &lt;span class="str"&gt;"&amp;lt;br&amp;gt;"&lt;/span&gt;);&lt;br /&gt;            response.Write(executedSQL);&lt;br /&gt;&lt;br /&gt;            NHibernateSQLMonitor.ClearExecutedSQL();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Dispose()&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="rem"&gt;//Not required&lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt&lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now there is one final step that should be done – the HttpModule needs to be registered in the config file of the application. To do it open the web.config file, find the &lt;strong&gt;&amp;lt;httpModules&amp;gt;&lt;/strong&gt; section (&lt;strong&gt;&amp;lt;modules&amp;gt; &lt;/strong&gt;if you are running IIS7) and place the following line there:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&amp;lt;add name=&lt;span class="str"&gt;"NHibernateSQLMonitor"&lt;br /&gt;&lt;/span&gt; type=&lt;span class="str"&gt;"Data.NHibernateSQLMonitorModule, Data"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt&lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;strong&gt;Data&lt;/strong&gt; is the assembly name where the &lt;strong&gt;NHibernateSQLMonitorModule&lt;/strong&gt; class is defined. Now everything is ready and if there are no compilation errors you should see something like this:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_2e9-Lk8T3Tg/S1JGWFsdafI/AAAAAAAAE4I/Pjg5_yR7ICE/s1600-h/image%5B8%5D.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_2e9-Lk8T3Tg/S1JGWu5q5VI/AAAAAAAAE4M/rbxmNGpsKlw/image_thumb%5B6%5D.png?imgmax=800" width="559" height="437" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;After adding new record, the page will look like this:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_2e9-Lk8T3Tg/S1JGXEDR0YI/AAAAAAAAE4Q/cLElac4LTf4/s1600-h/image%5B14%5D.png"&gt;&lt;img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_2e9-Lk8T3Tg/S1JGX1meI4I/AAAAAAAAE4U/_YDmwzl1jJE/image_thumb%5B10%5D.png?imgmax=800" width="569" height="421" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;So, what about improvements:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Instead of using NHibernate interceptor for monitoring the executed SQL it is possible to display the output from the Log4Net. The log4net output contains the SQL parameter values which may be a great benefit. As you may have noticed, the values in the screenshot above are replaced by the ? character.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The current version uses static variable to hold the executed SQL. If there is more than one user interacting with the application, this will lead to some synchronization problems. For example, you can extend the NHibernateSQLMonitor class to use the ASP.NET Session store. This way the user will see only the SQL code executed as a result of his actions.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;P.S. This post was inspired long time ago after reading the &lt;a href="http://blog.codeville.net/"&gt;Steve Sanderson’s&lt;/a&gt; &lt;a href="http://www.amazon.com/Pro-ASP-NET-Framework-Steven-Sanderson/dp/1430210079/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1263681882&amp;amp;sr=8-1"&gt;Pro ASP.NET MVC Framework&lt;/a&gt;. He has a similar application that connects to Linq to SQL and displays the executed SQL.&lt;/p&gt;</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/2565575548025617900/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=2565575548025617900" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/2565575548025617900?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/2565575548025617900?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2010/01/nhibernate-display-executed-sql-at.html" title="NHibernate: Display executed SQL at the bottom of an ASP.NET page (MVC or WebForms)" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/_2e9-Lk8T3Tg/S1JGWu5q5VI/AAAAAAAAE4M/rbxmNGpsKlw/s72-c/image_thumb%5B6%5D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkMCRXc_fSp7ImA9WxBTE0o.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-7482160325282690878</id><published>2009-12-09T16:54:00.001+02:00</published><updated>2009-12-09T16:54:24.945+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-09T16:54:24.945+02:00</app:edited><title>eBay Architecture</title><content type="html">&lt;p&gt;Recently I was curious to find out how big sites like &lt;a href="http://www.ebay.com/"&gt;eBay&lt;/a&gt; are build and running. After a quick research I was able to find some quite interesting articles.&lt;/p&gt; &lt;p&gt;I was surprised to find out that eBay doesn't use transactions. As well they do not use foreign keys in their database (the same thing as the SharePoint_AdminContent database). It looks like this is the latest trend ;-)&lt;/p&gt; &lt;p&gt;If you are curious like me, take a look at the following:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.infoq.com/presentations/shoup-ebay-architectural-principles"&gt;Randy Shoup on eBay's Architectural Principles&lt;/a&gt;&lt;br&gt;&lt;a href="http://qconsf.com/sf2009/file?path=/QConSF2007/slides/public/RandyShoup_eBayArchPrinciples.pdf"&gt;eBay Architectural Strategies, Patterns, and Forces&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.se-radio.net/podcast/2008-09/episode-109-ebay039s-architecture-principles-randy-shoup"&gt;Software Engineering Radio: eBay's Architecture Principles with Randy Shoup&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.infoq.com/articles/ebay-scalability-best-practices"&gt;Scalability Best Practices: Lessons from eBay&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.infoq.com/interviews/dan-pritchett-ebay-architecture"&gt;Dan Pritchett on Architecture at eBay&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.addsimplicity.com/adding_simplicity_an_engi/2006/11/you_scaled_your.html"&gt;You Scaled Your What?&lt;/a&gt;&lt;br&gt;&lt;a href="http://highscalability.com/blog/2008/5/27/ebay-architecture.html"&gt;High Scalability: eBay Architecture&lt;/a&gt;&lt;/p&gt;  </content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/7482160325282690878/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=7482160325282690878" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7482160325282690878?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7482160325282690878?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2009/12/ebay-architecture.html" title="eBay Architecture" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CE8CRngzeyp7ImA9WhJWEEg.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-2287795287986025262</id><published>2009-08-24T23:48:00.003+03:00</published><updated>2012-08-15T20:47:47.683+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-15T20:47:47.683+03:00</app:edited><title>jQuery FullCalendar and ASP.NET MVC</title><content type="html">Recently I had to integrate &lt;a href="http://jquery.com/" target="_blank"&gt;jQuery&lt;/a&gt; &lt;a href="http://arshaw.com/fullcalendar/" target="_blank"&gt;FullCalendar&lt;/a&gt; into &lt;a href="http://www.asp.net/mvc/" target="_blank"&gt;ASP.NET MVC&lt;/a&gt; application. Up to now I was not able to find such an example, so I will try to provide one. I assume that you are familiar with ASP.NET MVC, jQuery and FullCalendar component, so I’m not going to introduce each technology.&lt;br /&gt;
&lt;table border="0" cellpadding="2" cellspacing="0" &gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign="top" width="200"&gt;&lt;a href="http://lh5.ggpht.com/_2e9-Lk8T3Tg/SpRD9AJEY2I/AAAAAAAAEZI/LKYj3chRRsE/s1600-h/image3%5B1%5D.png"&gt;&lt;img alt="image" border="0" height="272" src="http://lh4.ggpht.com/_2e9-Lk8T3Tg/SpL99kWvD9I/AAAAAAAAEZM/C7jlbob8JrU/image3_thumb.png?imgmax=800" style="border: 0px currentColor; display: inline;" title="image" width="194" /&gt;&lt;/a&gt; &lt;/td&gt;&lt;td valign="top"&gt;I will use the default ASP.NET MVC Web Application template to create new project. Please, note that the jQuery is included by default, so there is no need to download and reference it.&lt;br /&gt;
The first step would be to place FullCalendar JavaScript and style-sheet files inside project’s Scripts and Content directory as shown in the picture.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Then we need to reference the files we just added to our project. I will do it by placing the following lines of code inside the &lt;strong&gt;&amp;lt;head&amp;gt;&lt;/strong&gt; section of &lt;strong&gt;Site.Master&lt;/strong&gt; file:&lt;br /&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:ContentPlaceHolder&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="TitleContent"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;link&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="../../Content/Site.css"&lt;/span&gt; &lt;span class="attr"&gt;rel&lt;/span&gt;&lt;span class="kwrd"&gt;="stylesheet"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/css"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;link&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="../../Content/fullcalendar.css"&lt;/span&gt; &lt;span class="attr"&gt;rel&lt;/span&gt;&lt;span class="kwrd"&gt;="stylesheet"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/css"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="../../Scripts/jquery-1.3.2.js"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &amp;lt;script src=&lt;span class="str"&gt;"../../Scripts/fullcalendar.js"&lt;/span&gt; type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Now we are ready to use the calendar routines inside our views. How to do it? Just create a &lt;strong&gt;div&lt;/strong&gt; tag and render the calendar’s HTML code inside. Here is how to modify Home’s Index.aspx:&lt;br /&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="indexContent"&lt;/span&gt; &lt;span class="attr"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span class="kwrd"&gt;="MainContent"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
       $(document).ready(&lt;span class="kwrd"&gt;function&lt;/span&gt;() {
           $(&lt;span class="str"&gt;'#calendar'&lt;/span&gt;).fullCalendar({
               events: &lt;span class="str"&gt;"/Home/CalendarData"&lt;/span&gt;
           });
       });  
   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="calendar"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
The code above will render the calendar’s HTML inside a div with id=”calendar”. The calendar data will be delivered by invoking the following URL: &lt;em&gt;/Home/CalendarData&lt;/em&gt;. This corresponds to &lt;em&gt;CalendarData&lt;/em&gt; method from the &lt;em&gt;Home&lt;/em&gt; controller. This controller is supposed to return the data in &lt;a href="http://www.json.org/" target="_blank"&gt;Json&lt;/a&gt; format. Here is a sample implementation:&lt;br /&gt;
&lt;pre class="csharpcode"&gt;    [HandleError]
   &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; HomeController : Controller
   {
       &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult CalendarData()
       {
           IList&amp;lt;CalendarDTO&amp;gt; tasksList = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;CalendarDTO&amp;gt;();

           tasksList.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; CalendarDTO
           {
               id = 1,
               title = &lt;span class="str"&gt;"Google search"&lt;/span&gt;,
               start = ToUnixTimespan(DateTime.Now),
               end = ToUnixTimespan(DateTime.Now.AddHours(4)),
               url = &lt;span class="str"&gt;"www.google.com"&lt;/span&gt;
           });
           tasksList.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; CalendarDTO
           {
               id = 1,
               title = &lt;span class="str"&gt;"Bing search"&lt;/span&gt;,
               start = ToUnixTimespan(DateTime.Now.AddDays(1)),
               end = ToUnixTimespan(DateTime.Now.AddDays(1).AddHours(4)),
               url = &lt;span class="str"&gt;"www.bing.com"&lt;/span&gt;
           });

           &lt;span class="kwrd"&gt;return&lt;/span&gt; Json(tasksList);
       }

       &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; ToUnixTimespan(DateTime date)
       {
           TimeSpan tspan = date.ToUniversalTime().Subtract(
    &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(1970, 1, 1, 0, 0, 0));

           &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;long&lt;/span&gt;)Math.Truncate(tspan.TotalSeconds);
       }

       &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Index()
       {
           &lt;span class="kwrd"&gt;return&lt;/span&gt; View();
       }

       &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult About()
       {
           &lt;span class="kwrd"&gt;return&lt;/span&gt; View();
       }
   }&lt;/pre&gt;
The code above creates two calendar entries called “Google search” and “Bing search”. Everything should be pretty simple, except the stuff around ToUnixTimespan routine.&lt;br /&gt;
There is well known problem with serialization of dates in Json format. There is no strict standard, so there are several approaches to this problem. For example, take a look &lt;a href="http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx" target="_blank"&gt;here&lt;/a&gt;. The implementation adopted by Microsoft was not recognized by FullCalendar, so I had to introduce the ToUnixTimespan routine. Basically, this routine returns the seconds after 1/1/1970.&lt;br /&gt;
Because of the above, you should notice that the &lt;em&gt;start&lt;/em&gt; and &lt;em&gt;end&lt;/em&gt; dates are represented as int:&lt;br /&gt;
&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CalendarDTO
   {
       &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; id { get; set; }
       &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; title { get; set; }
       &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; start { get; set; }
       &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; end { get; set; }
       &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; url { get; set; }
   }&lt;/pre&gt;
If you have done everything correct, the final result will be&lt;br /&gt;
&lt;a href="http://lh3.ggpht.com/_2e9-Lk8T3Tg/SpMFwMPT42I/AAAAAAAAEZA/A8gHejD-nOE/s1600-h/image%5B15%5D.png"&gt;&lt;img alt="image" border="0" height="643" src="http://lh4.ggpht.com/_2e9-Lk8T3Tg/SpMFw5LJmbI/AAAAAAAAEZE/Gx21nDq8QXc/image_thumb%5B9%5D.png?imgmax=800" style="border: 0px currentColor; display: inline;" title="image" width="655" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Enjoy!</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/2287795287986025262/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=2287795287986025262" title="15 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/2287795287986025262?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/2287795287986025262?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2009/08/jquery-fullcalendar-and-aspnet-mvc.html" title="jQuery FullCalendar and ASP.NET MVC" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_2e9-Lk8T3Tg/SpL99kWvD9I/AAAAAAAAEZM/C7jlbob8JrU/s72-c/image3_thumb.png?imgmax=800" height="72" width="72" /><thr:total>15</thr:total></entry><entry gd:etag="W/&quot;D0cBQXo-fip7ImA9WB5RFE4.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-4509996852463838718</id><published>2007-06-21T16:36:00.000+03:00</published><updated>2007-06-21T17:10:50.456+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-06-21T17:10:50.456+03:00</app:edited><title>Anti-development methodologies</title><content type="html">Software industry is growing constantly and development methodologies are following the same trend. Internet is full with shiny articles describing each methodology and all the benefit. Most of the people I'm talking are bored when they hear stuff like this. If you are like them, don't miss &lt;a href="http://www.scottberkun.com/blog/2007/asshole-driven-development/"&gt;this&lt;/a&gt; article. A friend of mine just send me the link. Also, check out the comments. All of them are about dummy development practices. Some of the titles are cynical, but there is a lot of truth in each line.&lt;br /&gt;Enjoy!</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/4509996852463838718/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=4509996852463838718" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/4509996852463838718?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/4509996852463838718?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2007/06/software-industry-is-growing-constantly.html" title="Anti-development methodologies" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEUDRn87cCp7ImA9WBFUFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-4197451598643969719</id><published>2007-04-27T10:57:00.000+03:00</published><updated>2007-04-27T11:24:37.108+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-04-27T11:24:37.108+03:00</app:edited><title>BrainStorm Rocks</title><content type="html">Yesterday was a great day. My team called &lt;a href="http://imaginecup.com/MyStuff/MyTeam.aspx?TeamID=169"&gt;BrainStorm&lt;/a&gt; won the local round of Microsoft's &lt;a href="http://imaginecup.com/"&gt;Imagine Cup 2007&lt;/a&gt; competition in the area of software design.&lt;br /&gt;Our project with the code name &lt;a href="http://bookvar.blogspot.com/"&gt;Bookvar&lt;/a&gt; will compete in the finals this year in Seoul, Korea. This was possible, because of the remarkable team I'm part of. Right now I can't find appropriate words to describe them, but as one of the jury said: "I had the chance to watch these young motivated and smart people". It's a great pleasure to work with each one of them.&lt;br /&gt;Although we managed to win the local round, there is still much work to be done. Lucky for us, the finals are after 3 months.&lt;br /&gt;Check out &lt;a href="http://xman892.blogspot.com/2007/04/imagine-cup-bulgaria-07-summary.html"&gt;this&lt;/a&gt; post from Ruslan Trifonov if you want to see some pictures from the event. Ruslan was member of the jury.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/4197451598643969719/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=4197451598643969719" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/4197451598643969719?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/4197451598643969719?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2007/04/brainstorm-rocks.html" title="BrainStorm Rocks" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;CkcNQn04fCp7ImA9WBFQF0U.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-3272932276865588531</id><published>2007-03-13T11:55:00.000+02:00</published><updated>2007-03-13T12:01:33.334+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-03-13T12:01:33.334+02:00</app:edited><title>Grand Prix Racing Online</title><content type="html">Last week I was chatting with an old friend of mine - Vladimir Alexandrov. I was surprised to find out that he is driving the &lt;a href="http://www.gpro.se"&gt;Grand Prix Racing Online&lt;/a&gt; site. Basically this is a F1 on-line simulator. If you are a F1 fan you will appreciate what Vladimir and his team is doing. The site is completely free and guess what - no advertisements are present.&lt;br /&gt;There are some interesting issues about the implementation and hosting, but because of security I can not share them.&lt;br /&gt;Good luck Vlado, and continue with the great job.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/3272932276865588531/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=3272932276865588531" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/3272932276865588531?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/3272932276865588531?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2007/03/grand-prix-racing-online.html" title="Grand Prix Racing Online" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkMMQHw9cSp7ImA9WBFQF0w.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-8521084598645771051</id><published>2007-03-12T17:34:00.000+02:00</published><updated>2007-03-12T17:48:01.269+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-03-12T17:48:01.269+02:00</app:edited><title>NHibernate and triggers</title><content type="html">Recently I was asked from a college of mine, about the following exception in application based on SQL Server 2005 and NHibernate :&lt;br /&gt;&lt;blockquote&gt;[NHibernate.AdoNet.TooManyRowsAffectedException] {"Unexpected row count: 2; expected: 1"} NHibernate.AdoNet.TooManyRowsAffectedException&lt;/blockquote&gt;&lt;br /&gt;After a quick investigation the problem was obvious - the exception raises when a row from a table is updated and the row has fired a trigger which executes an update statement.&lt;br /&gt;I have faced with this problem since early beta of NHibernate (0.8.4 as far as I can remember). Till now the only solution I have found is to use &lt;strong&gt;SET NOCOUNT&lt;/strong&gt; to stop the message that shows the number of rows affected by a Transact-SQL statement from being returned as part of the results.&lt;br /&gt;Just place SET NOCOUNT ON before the UPDATE statement inside the trigger and then after the UPDATE statement place SET NOCOUNT OFF. This will solve the problem.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/8521084598645771051/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=8521084598645771051" title="13 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/8521084598645771051?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/8521084598645771051?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2007/03/nhibernate-and-triggers.html" title="NHibernate and triggers" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>13</thr:total></entry><entry gd:etag="W/&quot;DkUCR347eSp7ImA9WBFQF0w.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-7133943764220490636</id><published>2007-03-12T17:29:00.000+02:00</published><updated>2007-03-12T17:44:26.001+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-03-12T17:44:26.001+02:00</app:edited><title>ASP.NET Web Part editor in pop-up dialog</title><content type="html">Last hour I was wondering how to host a ASP.NET Web Part editor control inside a pop-up dialog. I was lucky to find &lt;a href="http://markitup.com/Posts/Post.aspx?postId=a20e70f2-7eb1-40b6-b498-5bf4cb7b6edd"&gt;this&lt;/a&gt; implementation. It is based on some tricks, but resolves the problem.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/7133943764220490636/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=7133943764220490636" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7133943764220490636?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7133943764220490636?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2007/03/aspnet-web-part-editor-in-pop-up-dialog.html" title="ASP.NET Web Part editor in pop-up dialog" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;DEcASHgyfSp7ImA9WBBVFk8.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-1928824890732386770</id><published>2006-12-20T16:46:00.000+02:00</published><updated>2006-12-20T16:47:29.695+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-12-20T16:47:29.695+02:00</app:edited><title>First Bulgarian .NET Book is here</title><content type="html">Second volume from the first Bulgarian book about .NET is out. You can download free copy from &lt;a href="http://www.devbg.org/dotnetbook"&gt;here&lt;/a&gt;. Printed version will be available after a month.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/1928824890732386770/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=1928824890732386770" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/1928824890732386770?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/1928824890732386770?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/12/first-bulgarian-net-book-is-here.html" title="First Bulgarian .NET Book is here" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DE4BQX48eSp7ImA9WBBQF0g.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-7197725586332312014</id><published>2006-11-17T11:46:00.000+02:00</published><updated>2006-11-17T11:49:10.071+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-17T11:49:10.071+02:00</app:edited><title>Windows Forms data binding and notification of changed properties</title><content type="html">&lt;p&gt;Yesterday a college of mine asked me a question: "How to refresh TextBox control in Windows forms application binded to a property of object, when the property change its value?". The solution is very simple, but according to me not very well documented (at least in books I read).&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Solution: Provide event named &lt;em&gt;PropertyName&lt;/em&gt;Changed, where &lt;em&gt;PropertyName&lt;/em&gt; is the name of property binded to the TextBox. During the binding process, the text box inspects binded object for event with the mentioned signature and binds to it. The sample code looks like this:&lt;/p&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1251\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 public\cf0  \cf2 class\cf0  \cf10 Customer\par ??\cf0 \{\par ??    \cf2 private\cf0  \cf2 string\cf0  mName;\par ??\par ??    \cf2 public\cf0  \cf2 string\cf0  Name\par ??    \{\par ??        \cf2 get\cf0  \{ \cf2 return\cf0  mName; \}\par ??        \cf2 set\par ??\cf0         \{\par ??            mName = \cf2 value\cf0 ;\par ??            \cf2 if\cf0  (NameChanged != \cf2 null\cf0 )\par ??            \{\par ??                NameChanged(\cf2 this\cf0 , \cf10 EventArgs\cf0 .Empty);\par ??            \}\par ??        \}\par ??    \}\par ??\par ??    \cf2 public\cf0  \cf2 event\cf0  \cf10 EventHandler\cf0  NameChanged;\par ??\}\par ??\par ??Customer cust = \cf2 new\cf0  Customer();\par ??textBox1.DataBindings.Add(\cf13 "Text"\cf0 , cust, \cf13 "Name"\cf0 );\par ??} --&gt;&lt;br /&gt;&lt;div style="BACKGROUND: white;font-family:courier new;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:teal;"&gt;Customer&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;{&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; mName;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; Name&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; mName; }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;set&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            mName = &lt;span style="color:blue;"&gt;value&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:blue;"&gt;if&lt;/span&gt; (NameChanged != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                NameChanged(&lt;span style="color:blue;"&gt;this&lt;/span&gt;, &lt;span style="color:teal;"&gt;EventArgs&lt;/span&gt;.Empty);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;event&lt;/span&gt; &lt;span style="color:teal;"&gt;EventHandler&lt;/span&gt; NameChanged;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;}&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;Customer cust = &lt;span style="color:blue;"&gt;new&lt;/span&gt; Customer();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;textBox1.DataBindings.Add(&lt;span style="color:maroon;"&gt;"Text"&lt;/span&gt;, cust, &lt;span style="color:maroon;"&gt;"Name"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;/pre&gt;&lt;/div&gt;Another possible solution is to remove and add binding of the text box to the object. You can write general routine to loop through each control for a given form and remove-add binding. This is nasty solution of course.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/7197725586332312014/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=7197725586332312014" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7197725586332312014?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/7197725586332312014?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/11/windows-forms-data-binding-and.html" title="Windows Forms data binding and notification of changed properties" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>4</thr:total></entry><entry gd:etag="W/&quot;CEEAQX08fCp7ImA9WBBRFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-115799569610052451</id><published>2006-09-11T20:21:00.000+03:00</published><updated>2006-11-04T19:50:40.374+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-04T19:50:40.374+02:00</app:edited><title>Cool conference in Bulgaria</title><content type="html">&lt;a href="http://www.devreach.com/"&gt;DevReach&lt;/a&gt; - one of the most exiting conferences about Microsoft technologies in Bulgaria is coming. According to the program, some of the world leading industry speakers will present quite interesting lectures. Hope we will meet there.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/115799569610052451/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=115799569610052451" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115799569610052451?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115799569610052451?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/09/cool-conference-in-bulgaria.html" title="Cool conference in Bulgaria" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEAQXwycCp7ImA9WBBRFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-115799496346969013</id><published>2006-09-11T20:01:00.000+03:00</published><updated>2006-11-04T19:50:40.298+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-04T19:50:40.298+02:00</app:edited><title>Google toolbar 4</title><content type="html">This morning I was amazed! A few minutes after turning on my PC a small balloon appeared. The message in the balloon was something about Google toolbar update. Who cares, was my first reaction. But when the update was finished I was surprised to learn that &lt;strong&gt;LONG WAITING FEATURES LIKE ACCESSING BOOKMARKS FROM ANY COMPUTER&lt;/strong&gt; are already present. Believe me - this is like a elixir of life for me. I'm using one PC at work, one PC at home and one laptop. Managing bookmarks in situation like this is almost nightmare. In the past there were some other decision of this problem, but none of them was so elegant as Google toolbar. BTW, Microsoft are developing the same service, but as far as I know this feature is still in beta.&lt;br /&gt;The other features I like are SpellCheck and Translate. If you are inspired, install the toolbar from &lt;a href="http://toolbar.google.com/T4/index_xp.html"&gt;here&lt;/a&gt; for WinXP and IE. Enjoy!</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/115799496346969013/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=115799496346969013" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115799496346969013?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115799496346969013?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/09/google-toolbar-4.html" title="Google toolbar 4" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CEEAQXw5fyp7ImA9WBBRFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-115735061566417978</id><published>2006-09-04T09:15:00.000+03:00</published><updated>2006-11-04T19:50:40.227+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-04T19:50:40.227+02:00</app:edited><title>ADO.NET Entity Framework ContextObject and ASP.NET application</title><content type="html">Last month Microsoft published first CTP of ADO.NET Entity Framework. For more info - look &lt;a href="http://szahariev.blogspot.com/2006/08/adonet-vnext-ctp-is-out.html"&gt;here&lt;/a&gt;. Although Microsoft is still planning integration between Entity Framework and ASP.NET, I want to show you how to handle ADO.NET Entity Framewrok context object in ASP.NET application. This post is inspired from &lt;a href="http://szahariev.blogspot.com/2006/07/nhibernate-session-management.html"&gt;NHibernate session management&lt;/a&gt;.&lt;br /&gt;The idea is simple: Context object will be stored in ASP.NET session and after the request HTTPModule will free it. I'm using ASP.NET session instead of ASP.NET context to further extend this example to support session per application transaction strategy. If you are wondering what is "session per application transaction" take a look at &lt;a href="http://szahariev.blogspot.com/2006/07/nhibernate-session-management.html"&gt;NHibernate session management&lt;/a&gt;. Here is the code of the implementation:&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof1251\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 public\cf0  \cf2 class\cf0  \cf10 ContextManager\cf0 &amp;lt;T&amp;gt;\cf2 where\cf0  T: \cf10 ObjectContext\cf0 , \cf2 new\cf0 ()\par ??\{\par ??    \cf2 public\cf0  \cf2 static\cf0  T ObjectContext\par ??    \{\par ??        \cf2 get\par ??\cf0         \{\par ??            T resultContext;\par ??\par ??            \cf2 if\cf0  (\cf10 HttpContext\cf0 .Current.Items.Contains(\par ??                \cf10 ContextConst\cf0 .CONTEXT_OBJECT_SESSION_KEY))\par ??            \{\par ??                resultContext =\par ??                    (T)\cf10 HttpContext\cf0 .Current.Items[\par ??                        \cf10 ContextConst\cf0 .CONTEXT_OBJECT_SESSION_KEY];\par ??            \}\par ??            \cf2 else\par ??\cf0             \{\par ??                resultContext = \cf2 new\cf0  T();\par ??                \cf10 HttpContext\cf0 .Current.Items[\cf10 ContextConst\cf0 .CONTEXT_OBJECT_SESSION_KEY] = \par ??                    resultContext;\par ??            \}\par ??\par ??            \cf2 return\cf0  resultContext;\par ??        \}\par ??    \}\par ??\par ??    \cf2 public\cf0  \cf2 static\cf0  \cf2 bool\cf0  isActiveObjectContext\par ??    \{\par ??        \cf2 get\par ??\cf0         \{ \par ??            \cf2 return\cf0  \cf10 HttpContext\cf0 .Current.Items.Contains(\par ??                \cf10 ContextConst\cf0 .CONTEXT_OBJECT_SESSION_KEY);\par ??        \}\par ??    \}\par ?? \}\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;ContextManager&lt;/span&gt;&amp;lt;T&amp;gt;&lt;span style="color: blue;"&gt;where&lt;/span&gt; T: &lt;span style="color: teal;"&gt;ObjectContext&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; T ObjectContext&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; T resultContext;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: teal;"&gt;HttpContext&lt;/span&gt;.Current.Items.Contains(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;ContextConst&lt;/span&gt;.CONTEXT_OBJECT_SESSION_KEY))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; resultContext =&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (T)&lt;span style="color: teal;"&gt;HttpContext&lt;/span&gt;.Current.Items[&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;ContextConst&lt;/span&gt;.CONTEXT_OBJECT_SESSION_KEY];&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; resultContext = &lt;span style="color: blue;"&gt;new&lt;/span&gt; T();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;HttpContext&lt;/span&gt;.Current.Items[&lt;span style="color: teal;"&gt;ContextConst&lt;/span&gt;.CONTEXT_OBJECT_SESSION_KEY] = &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; resultContext;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; resultContext;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; isActiveObjectContext&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;get&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: teal;"&gt;HttpContext&lt;/span&gt;.Current.Items.Contains(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;ContextConst&lt;/span&gt;.CONTEXT_OBJECT_SESSION_KEY);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;}&lt;/pre&gt;&lt;/div&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof1251\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 public\cf0  \cf2 class\cf0  \cf10 ContextHttpModule\cf0  : \cf10 IHttpModule\cf0  \par ??\{\par ??\cf2     #region\cf0  IHttpModule Members\par ??\par ??    \cf2 public\cf0  \cf2 void\cf0  Init(\cf10 HttpApplication\cf0  context)\par ??    \{\par ??        context.EndRequest += \cf2 new\cf0  \cf10 EventHandler\cf0 (OnEndRequest);\par ??    \}\par ??\par ??    \cf2 public\cf0  \cf2 void\cf0  Dispose()\par ??    \{\par ??        \cf11 //Intentionaly not implemented\par ??\cf0     \}\par ??\par ??    \cf2 public\cf0  \cf2 void\cf0  OnEndRequest(\cf10 Object\cf0  sender, \cf10 EventArgs\cf0  e)\par ??    \{\par ??        \cf2 if\cf0  (\cf10 HttpContext\cf0 .Current.Items.Contains(\cf10 ContextConst\cf0 .CONTEXT_OBJECT_SESSION_KEY))\par ??        \{\par ??            \cf10 ObjectContext\cf0  contextObject = \par ??                (\cf10 ObjectContext\cf0 )\cf10 HttpContext\cf0 .Current.Items[\par ??                    \cf10 ContextConst\cf0 .CONTEXT_OBJECT_SESSION_KEY];\par ??            \par ??            contextObject.Dispose();\par ??        \}\par ??    \}\par ??\par ??\cf2     #endregion\par ??\cf0 \}\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;ContextHttpModule&lt;/span&gt; : &lt;span style="color: teal;"&gt;IHttpModule&lt;/span&gt; &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; IHttpModule Members&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Init(&lt;span style="color: teal;"&gt;HttpApplication&lt;/span&gt; context)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; context.EndRequest += &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;EventHandler&lt;/span&gt;(OnEndRequest);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Dispose()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;//Intentionaly not implemented&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnEndRequest(&lt;span style="color: teal;"&gt;Object&lt;/span&gt; sender, &lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: teal;"&gt;HttpContext&lt;/span&gt;.Current.Items.Contains(&lt;span style="color: teal;"&gt;ContextConst&lt;/span&gt;.CONTEXT_OBJECT_SESSION_KEY))&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;ObjectContext&lt;/span&gt; contextObject = &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;span style="color: teal;"&gt;ObjectContext&lt;/span&gt;)&lt;span style="color: teal;"&gt;HttpContext&lt;/span&gt;.Current.Items[&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;ContextConst&lt;/span&gt;.CONTEXT_OBJECT_SESSION_KEY];&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; contextObject.Dispose();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof1251\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 internal\cf0  \cf2 class\cf0  \cf10 ContextConst\par ??\cf0 \{\par ??    \cf2 public\cf0  \cf2 const\cf0  \cf2 string\cf0  CONTEXT_OBJECT_SESSION_KEY =\par ??        \cf13 "ContextConst.CONTEXT_OBJECT_SESSION_KEY"\cf0 ;\par ??\}\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;internal&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;ContextConst&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;const&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; CONTEXT_OBJECT_SESSION_KEY =&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: maroon;"&gt;"ContextConst.CONTEXT_OBJECT_SESSION_KEY"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Now, lets look how the code above can be used. First lets make some corrections to web.config file:&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 &amp;lt;\cf13 connectionStrings\cf2 &amp;gt;\par ??  &amp;lt;\cf13 add\cf2  \cf6 name\cf2 =\cf0 "\cf2 Duwamish7Model.Duwamish7\cf0 "\cf2  \par ??       \cf6 connectionString\cf2 =\cf0 "\cf2 metadata=C:\\Temp\\ContextObject\\Model;\par ??          mapping=C:\\Temp\\ContextObject\\Model;\par ??          provider=System.Data.SqlClient;\par ??          provider connection string=\cf6 &amp;amp;quot;\cf2 Data Source=ns-server;\par ??          Initial Catalog=Duwamish7;Integrated Security=True\cf6 &amp;amp;quot;\cf0 "\par ??\cf2     \cf6 providerName\cf2 =\cf0 "\cf2 System.Data.Mapping\cf0 "\cf2  /&amp;gt;\par ??&amp;lt;/\cf13 connectionStrings\cf2 &amp;gt;\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;add&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Duwamish7Model.Duwamish7&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;/span&gt;&lt;span style="color: red;"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;metadata=C:\Temp\ContextObject\Model;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mapping=C:\Temp\ContextObject\Model;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; provider=System.Data.SqlClient;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; provider connection string=&lt;/span&gt;&lt;span style="color: red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color: blue;"&gt;Data Source=ns-server;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Initial Catalog=Duwamish7;Integrated Security=True&lt;/span&gt;&lt;span style="color: red;"&gt;&amp;amp;quot;&lt;/span&gt;"&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color: red;"&gt;providerName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Data.Mapping&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 &amp;lt;\cf13 httpModules\cf2 &amp;gt;\par ??  &amp;lt;\cf13 add\cf2  \cf6 name\cf2 =\cf0 "\cf2 ContextObjectManager\cf0 "\par ??\cf2        \cf6 type\cf2 =\cf0 "\cf2 ObjectContextManager.ContextHttpModule, ObjectContextManager\cf0 "\cf2 /&amp;gt;\par ??&amp;lt;/\cf13 httpModules\cf2 &amp;gt;\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;httpModules&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;add&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ContextObjectManager&lt;/span&gt;"&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;/span&gt;&lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;ObjectContextManager.ContextHttpModule, ObjectContextManager&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;httpModules&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;Having all of the above done, we can write somethig like this:&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof1251\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf10 Duwamish7\cf0  db = \cf10 ContextManager\cf0 &amp;lt;\cf10 Duwamish7\cf0 &amp;gt;.ObjectContext;\par ??\par ??\cf10 Query\cf0 &amp;lt;\cf10 Authors\cf0 &amp;gt; query = db.GetQuery&amp;lt;\cf10 Authors\cf0 &amp;gt;(\par ??    \cf13 "SELECT VALUE a FROM Authors AS a WHERE a.PKId &amp;gt; 144"\cf0 );\par ??\par ??Repeater1.DataSource = query;\par ??Repeater1.DataBind();\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Duwamish7&lt;/span&gt; db = &lt;span style="color: teal;"&gt;ContextManager&lt;/span&gt;&amp;lt;&lt;span style="color: teal;"&gt;Duwamish7&lt;/span&gt;&amp;gt;.ObjectContext;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Query&lt;/span&gt;&amp;lt;&lt;span style="color: teal;"&gt;Authors&lt;/span&gt;&amp;gt; query = db.GetQuery&amp;lt;&lt;span style="color: teal;"&gt;Authors&lt;/span&gt;&amp;gt;(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: maroon;"&gt;"SELECT VALUE a FROM Authors AS a WHERE a.PKId &amp;gt; 144"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;Repeater1.DataSource = query;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;Repeater1.DataBind();&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;P.S. The code above is not tested for concurrency problems.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/115735061566417978/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=115735061566417978" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115735061566417978?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115735061566417978?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/09/adonet-entity-framework-contextobject.html" title="ADO.NET Entity Framework ContextObject and ASP.NET application" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEAQX8-fyp7ImA9WBBRFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-115729161993565785</id><published>2006-09-03T16:48:00.000+03:00</published><updated>2006-11-04T19:50:40.157+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-04T19:50:40.157+02:00</app:edited><title>WCF and WS Eventing</title><content type="html">WCF (aka Indigo) is the latest communication technology from Microsoft (still in beta). Although there are a lot of goodies in this technology, something really useful for me is missing - implementation of WS Eventing. If you are wondering why - &lt;a href="http://www.longhornblogs.com/robert/articles/VSLive_DonBox.aspx"&gt;this article&lt;/a&gt; gives the answer. Fortunately there is already non-Microsoft implementation. Read this &lt;a href="http://www.codeproject.com/useritems/WSEventing.asp"&gt;article&lt;/a&gt; if you are interested.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/115729161993565785/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=115729161993565785" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115729161993565785?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115729161993565785?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/09/wcf-and-ws-eventing.html" title="WCF and WS Eventing" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEAQX47eCp7ImA9WBBRFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-115640514286033089</id><published>2006-08-24T10:27:00.000+03:00</published><updated>2006-11-04T19:50:40.000+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-04T19:50:40.000+02:00</app:edited><title>Finally it is true!</title><content type="html">Yesterday, PFC Levski Sofia did it. The team had succeeded to qualify for the UEFA champions league group stage for the first time in Bulgarian football history. Although I'm fan of the &lt;a href="http://www.cska.bg/"&gt;CSKA Sofia&lt;/a&gt; the success of Levski makes me happy. More info - &lt;a href="http://www.uefa.com/competitions/UCL/FixturesResults/Round=2356/match=84632/Report=RP.html"&gt;here&lt;/a&gt;.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/115640514286033089/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=115640514286033089" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115640514286033089?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115640514286033089?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/08/finally-it-is-true.html" title="Finally it is true!" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEHSHc4fSp7ImA9WBBRFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-115634808600526927</id><published>2006-08-23T18:36:00.000+03:00</published><updated>2006-11-04T19:50:39.935+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-04T19:50:39.935+02:00</app:edited><title>Microsoft SQL Server and Ad-Hock queries optimization</title><content type="html">Yesterday I was surprised to learn that Microsoft SQL Server 2005 makes behind the scene parameterization of ad-hock queries. For example, lets have the following query:&lt;br /&gt;&lt;blockquote&gt;SELECT ID, Name FROM Article WHERE Price &gt; 100&lt;/blockquote&gt;&lt;br /&gt;SQL Server 2005 will replace constant literal values (100 in this example) by variables and this way query plan will be reuses for all queries similar to&lt;blockquote&gt;SELECT ID, Name FROM Article WHERE Price &gt; @p1&lt;/blockquote&gt;&lt;br /&gt;Not all of the ad-hock queries can be parameterized. If you are interested read &lt;a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx"&gt;this&lt;/a&gt; article.</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/115634808600526927/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=115634808600526927" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115634808600526927?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115634808600526927?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/08/microsoft-sql-server-and-ad-hock.html" title="Microsoft SQL Server and Ad-Hock queries optimization" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEEHSHY9fSp7ImA9WBBRFks.&quot;"><id>tag:blogger.com,1999:blog-31061699.post-115634437256870276</id><published>2006-08-23T17:31:00.000+03:00</published><updated>2006-11-04T19:50:39.865+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-11-04T19:50:39.865+02:00</app:edited><title>Attribute based transaction management and NHibernate</title><content type="html">In my previous post about &lt;a href="http://szahariev.blogspot.com/2006/07/nhibernate-session-management.html"&gt;NHibernate session management&lt;/a&gt; I presented a session per request strategy for session management in ASP.NET application. I will extend this example to show you how to declaratively manage transactions via attributes. Take a look at the GenericDAO.Save method:&lt;br /&gt;&lt;br /&gt;&lt;div style="BACKGROUND: white;font-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Save(T entity)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;{&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;bool&lt;/span&gt; manageTransaction = ! orm.isActiveTransaction;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;if&lt;/span&gt; (manageTransaction)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        orm.BeginTransaction(&lt;span style="color:teal;"&gt;IsolationLevel&lt;/span&gt;.ReadCommitted);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        orm.session.SaveOrUpdate(entity);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;if&lt;/span&gt; (manageTransaction)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            orm.CommitTransaction();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;span style="color:blue;"&gt;catch&lt;/span&gt;(&lt;span style="color:teal;"&gt;Exception&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;if&lt;/span&gt; (manageTransaction)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            orm.RollbackTransaction();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;throw&lt;/span&gt; e;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }            &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Almost 90% of the code is for transaction management. It will be nice if we can write something like:&lt;br /&gt;&lt;br /&gt;&lt;div style="BACKGROUND: white;font-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;[&lt;span style="color:teal;"&gt;Transaction&lt;/span&gt;(&lt;span style="color:teal;"&gt;IsolationLevel&lt;/span&gt;.ReadCommitted)]&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Save(T entity)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;{&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    mOrm.session.SaveOrUpdate(entity);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    mOrm.session.Flush();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;To achieve this, I will use &lt;a href="http://www.springframework.net"&gt;Spring.NET&lt;/a&gt; to intercept method call of the DAO. Before method marked with TransactionAttribute is executed a transaction will be started and then committed after method is executed. Although .NET provides solution for intercepting method calls via ContextBoundObject, I will use Spring.NET because this way my DAO object must implement just one interface instead of inheriting from ContextBoundObject.&lt;br /&gt;Lets begin with the implementation. First I will declare the attribute used to mark transaction sensitive methods:&lt;br /&gt;&lt;br /&gt;&lt;div style="BACKGROUND: white;font-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;[&lt;span style="color:teal;"&gt;AttributeUsage&lt;/span&gt;(&lt;span style="color:teal;"&gt;AttributeTargets&lt;/span&gt;.Method)]&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:teal;"&gt;TransactionAttribute&lt;/span&gt; : &lt;span style="color:teal;"&gt;Attribute&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;{&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:teal;"&gt;IsolationLevel&lt;/span&gt; mIsolationLevel;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; TransactionAttribute()&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        mIsolationLevel = &lt;span style="color:teal;"&gt;IsolationLevel&lt;/span&gt;.ReadCommitted;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; TransactionAttribute(&lt;span style="color:teal;"&gt;IsolationLevel&lt;/span&gt; aIsolation)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        mIsolationLevel = aIsolation;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:teal;"&gt;IsolationLevel&lt;/span&gt; isolationLevel&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;get&lt;/span&gt; { &lt;span style="color:blue;"&gt;return&lt;/span&gt; mIsolationLevel; }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;set&lt;/span&gt; { mIsolationLevel = &lt;span style="color:blue;"&gt;value&lt;/span&gt;; }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Now I will decrare the class responsible for starting and committing transactions. There are a lot of specific issues about method interception and Spring.NET so if you are not familiar with them read the documentation about &lt;a href="http://www.springframework.net"&gt;Spring.NET&lt;/a&gt;. The class looks like:&lt;br /&gt;&lt;br /&gt;&lt;div style="BACKGROUND: white;font-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:teal;"&gt;TransactionAroundAdvice&lt;/span&gt; : &lt;span style="color:teal;"&gt;IMethodInterceptor&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;{&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:teal;"&gt;OrmManager&lt;/span&gt; mOrm;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; TransactionAroundAdvice()&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        mOrm = &lt;span style="color:teal;"&gt;OrmManagerFactory&lt;/span&gt;.GetInstance();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:teal;"&gt;TransactionAttribute&lt;/span&gt; GetTransactionAttribute(&lt;span style="color:teal;"&gt;MethodInfo&lt;/span&gt; aMethod)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;object&lt;/span&gt;[] attributes = aMethod.GetCustomAttributes(&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:teal;"&gt;TransactionAttribute&lt;/span&gt;), &lt;span style="color:blue;"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;if&lt;/span&gt; (attributes.Length != 1)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:green;"&gt;//TODO: Throw more meaningfull exception and message&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:blue;"&gt;throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:teal;"&gt;Exception&lt;/span&gt;(&lt;span style="color:maroon;"&gt;"Transaction Attribute is missing"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;return&lt;/span&gt; (&lt;span style="color:teal;"&gt;TransactionAttribute&lt;/span&gt;)attributes[0];&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;object&lt;/span&gt; Invoke(&lt;span style="color:teal;"&gt;IMethodInvocation&lt;/span&gt; invocation)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;bool&lt;/span&gt; manageTransaction = ! mOrm.isActiveTransaction;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;if&lt;/span&gt; (manageTransaction)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:teal;"&gt;TransactionAttribute&lt;/span&gt; transactionAttribute =&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                GetTransactionAttribute(invocation.Method);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            mOrm.BeginTransaction(transactionAttribute.isolationLevel);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:green;"&gt;//TODO: Find way to compare isolation level from TransactionAttribute and&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:green;"&gt;//current active transaction if manageTransaction == false&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;object&lt;/span&gt; returnValue;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            returnValue = invocation.Proceed();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:blue;"&gt;if&lt;/span&gt; (manageTransaction)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                mOrm.CommitTransaction();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        }&lt;span style="color:blue;"&gt;catch&lt;/span&gt;(&lt;span style="color:teal;"&gt;Exception&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:blue;"&gt;if&lt;/span&gt; (manageTransaction)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                mOrm.RollbackTransaction();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:blue;"&gt;if&lt;/span&gt; ((e &lt;span style="color:blue;"&gt;is&lt;/span&gt; &lt;span style="color:teal;"&gt;TargetInvocationException&lt;/span&gt;) &amp;amp;&amp; (e.InnerException != &lt;span style="color:blue;"&gt;null&lt;/span&gt;))&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="color:green;"&gt;//Because when AOP is enables, method is invoked via reflection&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="color:green;"&gt;//TargetInvocationException is thrown. This exception is most likely&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="color:green;"&gt;//to confuse application developer, so it is removed&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="color:blue;"&gt;throw&lt;/span&gt; e.InnerException;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="color:blue;"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="color:blue;"&gt;throw&lt;/span&gt; e;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;            }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        }            &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="color:blue;"&gt;return&lt;/span&gt; returnValue;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;    }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;When a method marked with TransactionAttribute is intercepted then Invoke method from TransactionAroundAdvice class is called. Now lets see how our DAO class looks like when transaction management code is removed:&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof1251\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 public\cf0  \cf2 class\cf0  \cf10 AttributeEnabledDAO\cf0 &amp;lt;T&amp;gt;: \cf10 IDAO\cf0 &amp;lt;T&amp;gt;\par ??\{\par ??    \cf2 public\cf0  AttributeEnabledDAO()\par ??    \{\par ??        mOrm = \cf10 OrmManagerFactory\cf0 .GetInstance();\par ??    \}\par ??\par ??    \cf2 private\cf0  \cf10 OrmManager\cf0  mOrm;\par ??\par ??\cf2     #region\cf0  IDAO Members\par ??\par ??    \cf2 public\cf0  T Load(\cf2 object\cf0  id)\par ??    \{\par ??        \cf2 return\cf0  (T) mOrm.session.Load(\cf2 typeof\cf0 (T), id);\par ??    \}\par ??\par ??    [\cf10 Transaction\cf0 (\cf10 IsolationLevel\cf0 .ReadCommitted)]\par ??    \cf2 public\cf0  \cf2 void\cf0  Save(T entity)\par ??    \{\par ??        mOrm.session.SaveOrUpdate(entity);\par ??        mOrm.session.Flush();\par ??    \}\par ??\par ??\cf2     #endregion\par ??\cf0 \}\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;AttributeEnabledDAO&lt;/span&gt;&amp;lt;T&amp;gt;: &lt;span style="color: teal;"&gt;IDAO&lt;/span&gt;&amp;lt;T&amp;gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; AttributeEnabledDAO()&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mOrm = &lt;span style="color: teal;"&gt;OrmManagerFactory&lt;/span&gt;.GetInstance();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: teal;"&gt;OrmManager&lt;/span&gt; mOrm;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; IDAO Members&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; T Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; id)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; (T) mOrm.session.Load(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(T), id);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: teal;"&gt;Transaction&lt;/span&gt;(&lt;span style="color: teal;"&gt;IsolationLevel&lt;/span&gt;.ReadCommitted)]&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Save(T entity)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mOrm.session.SaveOrUpdate(entity);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mOrm.session.Flush();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Much more simple. Example of using AttributeEnabledDAO is given bellow:&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof1251\uc1 \deff0{\fonttbl{\f0\fnil\fcharset204\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf10 ProxyFactory\cf0  articleDAOFactory = \cf2 new\cf0  \cf10 ProxyFactory\cf0 (\par ??    \cf2 new\cf0  \cf10 AttributeEnabledDAO\cf0 &amp;lt;\cf10 Article\cf0 &amp;gt;());\par ??\par ??articleDAOFactory.AddAdvisor(\cf2 new\cf0  \cf10 DefaultPointcutAdvisor\cf0 (\par ??    \cf2 new\cf0  \cf10 AttributeMatchMethodPointcut\cf0 (\cf2 typeof\cf0 (\cf10 TransactionAttribute\cf0 )),\par ??    \cf2 new\cf0  \cf10 TransactionAroundAdvice\cf0 ()));\par ??\par ??\cf10 IDAO\cf0 &amp;lt;\cf10 Article\cf0 &amp;gt; articleDao;\par ??\cf2 lock\cf0  (synchObject)\par ??\{\par ??    articleDao = (\cf10 IDAO\cf0 &amp;lt;\cf10 Article\cf0 &amp;gt;) articleDAOFactory.GetProxy();\par ??\}\par ??\par ??\cf10 Article\cf0  article = articleDao.Load(1);\par ??article.Name = \cf13 "Paracetamol"\cf0 ;\par ??article.SalePrice = rnd.NextDouble();\par ??articleDao.Save(article);\par ??}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;ProxyFactory&lt;/span&gt; articleDAOFactory = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;ProxyFactory&lt;/span&gt;(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;AttributeEnabledDAO&lt;/span&gt;&amp;lt;&lt;span style="color: teal;"&gt;Article&lt;/span&gt;&amp;gt;());&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;articleDAOFactory.AddAdvisor(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;DefaultPointcutAdvisor&lt;/span&gt;(&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;AttributeMatchMethodPointcut&lt;/span&gt;(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color: teal;"&gt;TransactionAttribute&lt;/span&gt;)),&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;TransactionAroundAdvice&lt;/span&gt;()));&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;IDAO&lt;/span&gt;&amp;lt;&lt;span style="color: teal;"&gt;Article&lt;/span&gt;&amp;gt; articleDao;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;lock&lt;/span&gt; (synchObject)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; articleDao = (&lt;span style="color: teal;"&gt;IDAO&lt;/span&gt;&amp;lt;&lt;span style="color: teal;"&gt;Article&lt;/span&gt;&amp;gt;) articleDAOFactory.GetProxy();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Article&lt;/span&gt; article = articleDao.Load(1);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;article.Name = &lt;span style="color: maroon;"&gt;"Paracetamol"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;article.SalePrice = rnd.NextDouble();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;articleDao.Save(article);&lt;/pre&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://szahariev.blogspot.com/feeds/115634437256870276/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=31061699&amp;postID=115634437256870276" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115634437256870276?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/31061699/posts/default/115634437256870276?v=2" /><link rel="alternate" type="text/html" href="http://szahariev.blogspot.com/2006/08/attribute-based-transaction-management.html" title="Attribute based transaction management and NHibernate" /><author><name>Stephan Zahariev</name><uri>http://www.blogger.com/profile/11128408750332856474</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry></feed>
