I'm working on the project using Nhibernate 3.0 and Fluent Nhibernate. We are using SQL-Server 2008 for production purposes. For versioning we rely on SQL-Server side generated timestamps.
Recently I've started writing repository tests using in memory SQLite database. Unfortunately SQLite cannot generate timestamps, so any insert fails with constraint violation.
I want to change Version mapping to Nhibernate managed one, when I compile my mappings for SQLite underlying database. The code conveying this idea would look roughly like this:
public class CommonClassMap<T> : ClassMap<T> where T:Entity
{
public CommonClassMap()
{
if (SQLITE)
{
Version(n => n.Version);
}
else
{
Version(n => n.Version).CustomSqlType("timestamp").UnsavedValue("null").CustomType("BinaryBlob").
Generated.Always();
}
Unfortunately, I was not able to find any way to change mappings at the run-time or read underlying database information from the ClassMap. Any help is welcome.