I am starting to use Fluent nHibernate on a project and am trying to get the automapping to work. At the time I am stuck with the mapping of our database's timestamp fields into byte-arrays. We are using SQL Server 2008 as the database, and we are not generating the database from code.
What I have:
public class Entity
{
public virtual Guid RowID { get; protected set; }
public virtual byte[] ChangeCheck { get; protected set; }
public virtual string Data { get; set; }
}
Our database convention is to name the version field 'ChangeCheck'. I cannot seem to locate where I override the default behaviour of DefaultAutomappingConfiguration to use ChangeCheck as the auto-generated version field.
Is it possible to get a DefaultAutomappingConfiguration sub-class to automap all ChangeCheck fields into version fields?
Thanks for any pointers and help.
Optional solution:
Given I create an automap override for all entities using 'ChangeCheck' I could do the following:
private class ChangeCheckVersionConvention : IVersionConvention
{
public void Apply(IVersionInstance instance)
{
instance.Column("ChangeCheck");
instance.Generated.Always();
instance.UnsavedValue(null);
}
}
public class EntityOverride : IAutoMappingOverride<IssueReport>
{
public void Override(AutoMapping<IssueReport> mapping)
{
mapping.Version(m => m.ChangeCheck);
}
}
//....
var persistenceModel = AutoMap.AssemblyOf<MyConfiguration>(new MyConfiguration())
.UseOverridesFromAssemblyOf<MyConfiguration>()
.Conventions.Add<ChangeCheckVersionConvention>();
Which works, however I cannot figure out how to remove the override to get the ChangeCheck column set-up as my Version column without having to override all my entities.