Patterns & Practices

Patterns & Practices

NHibernate - Custom User Types and Collections

NHibernate is an extremely powerful ORM but sometimes its quite difficult to find information on how to do certain things and why other things are the way they are. Recently I've been working on generating NHibernate mapping files and a domain model with its classes using Visual Studio DSL tools. Below are some of the difficulties I came across and their solutions. Mapping Enums to string database representations Sometimes you have a database schema which requires you to provide things like "M" for male and "F" for female. It does not make sense to force your users to use a string for...

Response.Redirect and the ThreadAbortException

A colleague came across a problem recently where performance counters were showing a high exception to request ratio. In actual fact there were at 4 exceptions for every 1 request, that's 400% compared to the desired 5%. These seemed to be getting handled at some stage or another as there were no HttpUnhandledExceptions getting thrown at the UI. It turns out that Response.Redirect and Server.Transfer will throw a ThreadAbortException everytime the single parameter overload is called. i.e. Response.Redirect( string url ) The problem is that Response.Redirect will call a Response.End internally to stop code executing after the statement. This in turn throws our mystery...

Enterprise Library 3.0 Released - with some really nice features

The Microsoft Patterns and Practices team have just released Enterprise Library 3.0 - April 2007. This is the full RTM version of EntLib with some really neat new features: Validation Application Block. Allows you to centrally define validation rules using configuration or attributes, and easily validate data from anywhere in your application, including deep integration with Windows Forms, ASP.NET and WCF. Policy Injection Application Block. Provides a powerful approach for separating cross-cutting concerns from business logic using declarative policies that are attached at runtime to methods on your objects. Application Block Software Factory. Dramatically simplifies the process of building application blocks and...