views:

46

answers:

1

How do I map a Version property using conventions (e.g. IClassConvention, AutomapperConfiguration)?

public abstract class Entity
{
    ...
    public virtual int? Version { get; protected set; }
    ...
 }

<class ...>
    <version name="Version" column="version" generated="never" type="Int32" unsaved-value="0" />
</class>
A: 

Change the Version from an int? to an int.

FluentNHibernate automatically identifies a property called "Version" or "Timestamp" as a versioning field. However it must be one of a few types (int, long, TimeSpan, byte[]). See VersionStep in the FNH source.

You can customize this column with IVersionConvention (just not choose which property is your version). I saw a post from Fabio Maulo that hints this feature may be in the trunk already.

Brian