Wednesday, March 2, 2011

NHibernate FAQ: Add custom dialect

1. Write your custom Dialect class and inherit it from one of existing NHibernate dialecs:

using System;
using NHibernate.Dialect;
using NHibernate;

namespace MyAssembly
{
    public class MyCustomDialect : MsSql2008Dialect
    {
        public MyCustomDialect()
        {
        }
    }
}

2. In configuration file in hibernate configuration section specify your dialect class by full name (in this example "MyAssembly.MyCustomDialect"). Specify Assembly name if you class is in separate assembly (in this example "MyAssembly").
    MyAssembly.MyCustomDialect, MyAssembly