c# - Row versioning in NHibernate -


i'm developing social app, provide users create walls messages (like on fb) , invite friends. have table in db contains walls , version (in timestamp), meaning - last update time.

when updates wall, version updated , want user receive version. i'm using nhibernate , defined version row type of version, couldn't find way update row , receiving new version in 1 atomic action, prevent concurrency problems.

is there way this? there better way solve problem?

the base entity,

public abstract class auditbase {            private int? _rowversion = 0;      public virtual int? rowversion     {         { return _rowversion; }         set { _rowversion = value; }     } } 

the entity,

    public partial class axservices : auditbase {} 

you can try defaultupdateeventlistener , defaultsaveeventlistener

for example

    public class customsaveeventlistener : defaultsaveeventlistener {      protected override object performsave(object entity, object id, ientitypersister persister, bool useidentitycolumn, object anything, ieventsource source, bool requiresimmediateidaccess)     {         ((auditbase)entity).rowversion = 0;         object obj = base.performsave(entity, id, persister, useidentitycolumn, anything, source, requiresimmediateidaccess);   return obj;         }     } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -