当前位置: 首页>>代码示例>>C#>>正文


C# LockMode.GreaterThan方法代码示例

本文整理汇总了C#中LockMode.GreaterThan方法的典型用法代码示例。如果您正苦于以下问题:C# LockMode.GreaterThan方法的具体用法?C# LockMode.GreaterThan怎么用?C# LockMode.GreaterThan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LockMode的用法示例。


在下文中一共展示了LockMode.GreaterThan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpgradeLock

		/// <summary> 
		/// Performs a pessimistic lock upgrade on a given entity, if needed. 
		/// </summary>
		/// <param name="entity">The entity for which to upgrade the lock.</param>
		/// <param name="entry">The entity's EntityEntry instance.</param>
		/// <param name="requestedLockMode">The lock mode being requested for locking. </param>
		/// <param name="source">The session which is the source of the event being processed.</param>
		protected virtual void UpgradeLock(object entity, EntityEntry entry, LockMode requestedLockMode, ISessionImplementor source)
		{
			if (requestedLockMode.GreaterThan(entry.LockMode))
			{
				// The user requested a "greater" (i.e. more restrictive) form of
				// pessimistic lock
				if (entry.Status != Status.Loaded)
				{
					throw new ObjectDeletedException("attempted to lock a deleted instance", entry.Id, entry.EntityName);
				}

				IEntityPersister persister = entry.Persister;

				if (log.IsDebugEnabled)
				{
					log.Debug(string.Format("locking {0} in mode: {1}", MessageHelper.InfoString(persister, entry.Id, source.Factory), requestedLockMode));
				}

				ISoftLock slock;
				CacheKey ck;
				if (persister.HasCache)
				{
					ck = new CacheKey(entry.Id, persister.IdentifierType, persister.RootEntityName, source.EntityMode, source.Factory);
					slock = persister.Cache.Lock(ck, entry.Version);
				}
				else
				{
					ck = null;
					slock = null;
				}

				try
				{
					if (persister.IsVersioned && requestedLockMode == LockMode.Force)
					{
						// todo : should we check the current isolation mode explicitly?
						object nextVersion = persister.ForceVersionIncrement(entry.Id, entry.Version, source);
						entry.ForceLocked(entity, nextVersion);
					}
					else
					{
						persister.Lock(entry.Id, entry.Version, entity, requestedLockMode, source);
					}
					entry.LockMode = requestedLockMode;
				}
				finally
				{
					// the database now holds a lock + the object is flushed from the cache,
					// so release the soft lock
					if (persister.HasCache)
					{
						persister.Cache.Release(ck, slock);
					}
				}
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:63,代码来源:AbstractLockUpgradeEventListener.cs

示例2: NeedsLockHint

		private bool NeedsLockHint(LockMode lockMode)
		{
			return lockMode.GreaterThan(LockMode.Read);
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:4,代码来源:MsSql2000Dialect.cs

示例3: AppendLockHint

		public override string AppendLockHint(LockMode lockMode, string tableName)
		{
			if (lockMode.GreaterThan(LockMode.Read))
				return tableName + " holdlock";
			
			return tableName;
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:7,代码来源:SybaseASE15Dialect.cs

示例4: NeedsLockHint

		protected bool NeedsLockHint(LockMode lockMode)
		{
			return lockMode.GreaterThan(LockMode.Read);
		}
开发者ID:chKarner,项目名称:nhibernate-core,代码行数:4,代码来源:MsSql2000Dialect.cs

示例5: GetLockingStrategy

 public override ILockingStrategy GetLockingStrategy(ILockable lockable, LockMode lockMode)
 {
     if (lockMode.GreaterThan(LockMode.Read))
     {
         return new UpdateLockingStrategy(lockable, lockMode);
     }
     else
     {
         return new SelectLockingStrategy(lockable, lockMode);
     }
 }
开发者ID:mnjstwins,项目名称:NHibernate.CacheDb,代码行数:11,代码来源:Cache71Dialect.cs

示例6: UpgradeLock

		private void UpgradeLock( object obj, EntityEntry entry, LockMode lockMode )
		{
			if( lockMode.GreaterThan( entry.LockMode ) )
			{
				if( entry.Status != Status.Loaded )
				{
					throw new ObjectDeletedException( "attempted to lock a deleted instance", entry.Id, obj.GetType() );
				}

				IClassPersister persister = entry.Persister;

				if( log.IsDebugEnabled )
				{
					log.Debug( "locking " + MessageHelper.InfoString( persister, entry.Id ) + " in mode: " + lockMode );
				}

				ISoftLock myLock = null;
				if( persister.HasCache )
				{
					myLock = persister.Cache.Lock( entry.Id, entry.Version );
				}
				try
				{
					persister.Lock( entry.Id, entry.Version, obj, lockMode, this );
					entry.LockMode = lockMode;
				}
				finally
				{
					// the database now holds a lock + the object is flushed from the cache,
					// so release the soft lock
					if( persister.HasCache )
					{
						persister.Cache.Release( entry.Id, myLock );
					}
				}
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:37,代码来源:SessionImpl.cs


注:本文中的LockMode.GreaterThan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。