How do I map repeating columns in NHibernate without creating duplicate properties

Posted by Ian Oakes on Stack Overflow See other posts from Stack Overflow or by Ian Oakes
Published on 2010-03-29T00:27:20Z Indexed on 2010/03/29 23:43 UTC
Read the original article Hit count: 191

Filed under:

Given a database that has numerous repeating columns used for auditing and versioning, what is the best way to model it using NHibernate, without having to repeat each of the columns in each of the classes in the domain model?

Every table in the database repeats these same nine columns, the names and types are identical and I don't want to replicate it in the domain model.

I have read the docs and I saw the section on inheritance mapping but I couldn't see how to make it work in this scenario. This seems like a common scenario because nearly every database I've work on has had the four common audit columns (CreatedBy, CreateDate, UpdatedBy, UpdateDate) in nearly every table. This database is no different except that it introduces another five columns which are common to every table.

© Stack Overflow or respective owner

Related posts about nhibernate