1
votes

Why does ormlite require to name my version row RowVersion?

Check in code looks like this:

var isRowVersion = propertyInfo.Name == ModelDefinition.RowVersionName
                && propertyInfo.PropertyType == typeof(ulong);

and this implementation

var isRowVersion = propertyInfo.FirstAttribute<RowVersionAttribute>();

would be much more elegant and flexible (RowVersionAttribute already exists in ServiceStack.DataAnnotations) this would allow for usage byte[] as field type and would make it easier to move from Entity Framework.

Why is ModelDefinition.RowVersionName constant, and not static property or lambda, at least it would be possible to use different names. Is it possible to use columns with different name than RowVersion at the moment?

thanks

1
The SQL Server datatype is called ROWVERSION.... - marc_s

1 Answers

1
votes

RowVersion is implemented as a special property like Id where its signature is enforced as ulong RowVersion, e.g:

public class Poco
{
    ...
    public ulong RowVersion { get; set; }
}

This ensures that there's no disambiguation on what the signature and name should be and that there should be only 1 such property on each table (i.e. like Id). But just like other fields you can use [Alias] to map it to a pre-existing column with a different name.

Using ulong ensures RowVersion is implemented efficiently and consistently in all major RDBMS's, i.e:

  • Uses rowversion datatype in SqlServer
  • Uses PostgreSql's xmin system column (no column on table required)
  • Uses UPDATE triggers on MySql, Sqlite and Oracle whose lifetime is attached to Create/Drop tables APIs