.net and other musings

Ben Lovell, an agile developer living in the UK.

NHibernate Tip: Escaping column names

leave a comment »

Another quick NH tip. When escaping column names in mapping files, remember to use backticks i.e. `ColumnName` and not square brackets a la SQL Server i.e. [ColumnName]. NHibernate replaces backticks at runtime with the correct escaping sequence for your chosen database dialect thus aiding portability to other RDBMs.

While we're on the subject of databases and NHibernate, another little-known tip (for SQL Server) which a colleague mentioned to me: When specifying tables in your mapping files, prefix them with the database name and owner i.e. "Pubs.dbo.Authors". For a potentially significant performance increase when issuing complex queries via NHibernate. Although this does affect database portability slightly :)

Written by benl

April 21, 2006 at 11:56 am

Posted in NHibernate

Leave a Reply