NHibernate tricks

by MikeHogg 22. April 2013 19:51

 

When setting up Automapper you usually use a TableNameConvention that takes plurals, but if you are like me and working against an existing database, you can opt not to use it and save yourself the time of all those mapping.Table("Tablename") redundancies in your override maps.

 

Sharp Architecture and Templify is a great approach to internal or in-house starter library, although it is quick to branch and already with MVC4 out and MVCContrib deprecated, or simply out of date, I get the feeling that the main Sharp Architecture team project does not look like my version anymore.

One of the main things to do when setting it up out of the box with MVC4 is redirecting the old strong named dll references to the new ones.  It took four of them for me.  This appeared to be caused mostly by MVCContrib's strong typed controller actions, which is one of my favorite features.  I cannot find anything about this library being updated for MVC4 so I hesitate to put it in a new production project.  Also, I was disappointed to see magic string ActionLinks still in MVC4.  Anyway, I had to add this to my web.config...

 

 
 
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      	        <dependentAssembly>
        	            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
                <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>

Tags:

NHibernate

About Mike Hogg

Mike Hogg is a c# developer in Brooklyn.

More Here

Favorite Books

This book had the most influence on my coding style. It drastically changed the way I write code and turned me on to test driven development even if I don't always use it. It made me write clearer, functional-style code using more principles such as DRY, encapsulation, single responsibility, and more. amazon.com

This book opened my eyes to a methodical and systematic approach to upgrading legacy codebases step by step. Incrementally transforming code blocks into testable code before making improvements. amazon.com

More Here