本文整理汇总了C#中IEntityPersister.GetVersion方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityPersister.GetVersion方法的具体用法?C# IEntityPersister.GetVersion怎么用?C# IEntityPersister.GetVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntityPersister
的用法示例。
在下文中一共展示了IEntityPersister.GetVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsVersionChanged
private static bool IsVersionChanged(object entity, IEventSource source, IEntityPersister persister, object target)
{
if (!persister.IsVersioned)
{
return false;
}
// for merging of versioned entities, we consider the version having
// been changed only when:
// 1) the two version values are different;
// *AND*
// 2) The target actually represents database state!
//
// This second condition is a special case which allows
// an entity to be merged during the same transaction
// (though during a seperate operation) in which it was
// originally persisted/saved
bool changed =
!persister.VersionType.IsSame(persister.GetVersion(target, source.EntityMode),
persister.GetVersion(entity, source.EntityMode), source.EntityMode);
// TODO : perhaps we should additionally require that the incoming entity
// version be equivalent to the defined unsaved-value?
return changed && ExistsInDatabase(target, source, persister);
}
示例2: PerformUpdate
protected virtual void PerformUpdate(SaveOrUpdateEvent @event, object entity, IEntityPersister persister)
{
if (!persister.IsMutable)
{
log.Debug("immutable instance passed to PerformUpdate(), locking");
}
if (log.IsDebugEnabled)
{
log.Debug("updating " + MessageHelper.InfoString(persister, @event.RequestedId, @event.Session.Factory));
}
IEventSource source = @event.Session;
EntityKey key = new EntityKey(@event.RequestedId, persister, source.EntityMode);
source.PersistenceContext.CheckUniqueness(key, entity);
if (InvokeUpdateLifecycle(entity, persister, source))
{
Reassociate(@event, @event.Entity, @event.RequestedId, persister);
return;
}
// this is a transient object with existing persistent state not loaded by the session
new OnUpdateVisitor(source, @event.RequestedId, entity).Process(entity, persister);
//TODO: put this stuff back in to read snapshot from
// the second-level cache (needs some extra work)
/*Object[] cachedState = null;
if ( persister.hasCache() ) {
CacheEntry entry = (CacheEntry) persister.getCache()
.get( event.getRequestedId(), source.getTimestamp() );
cachedState = entry==null ?
null :
entry.getState(); //TODO: half-assemble this stuff
}*/
source.PersistenceContext.AddEntity(
entity,
persister.IsMutable ? Status.Loaded : Status.ReadOnly,
null,
key,
persister.GetVersion(entity, source.EntityMode),
LockMode.None,
true,
persister,
false,
true);
//persister.AfterReassociate(entity, source); TODO H3.2 not ported
if (log.IsDebugEnabled)
{
log.Debug("updating " + MessageHelper.InfoString(persister, @event.RequestedId, source.Factory));
}
CascadeOnUpdate(@event, persister, entity);
}