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


C# LockMode.LessThan方法代码示例

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


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

示例1: UpdateLockingStrategy

		/// <summary> 
		/// Construct a locking strategy based on SQL UPDATE statements.
		/// </summary>
		/// <param name="lockable">The metadata for the entity to be locked. </param>
		/// <param name="lockMode">Indictates the type of lock to be acquired. </param>
		/// <remarks>
		/// read-locks are not valid for this strategy.
		/// </remarks>
		public UpdateLockingStrategy(ILockable lockable, LockMode lockMode)
		{
			this.lockable = lockable;
			this.lockMode = lockMode;
			if (lockMode.LessThan(LockMode.Upgrade))
			{
				throw new HibernateException("[" + lockMode + "] not valid for update statement");
			}
			if (!lockable.IsVersioned)
			{
				log.Warn("write locks via update not supported for non-versioned entities [" + lockable.EntityName + "]");
				sql = null;
			}
			else
			{
				sql = GenerateLockString();
			}
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:26,代码来源:UpdateLockingStrategy.cs

示例2: DoLoad

		/// <summary>
		/// Actually do all the hard work of loading up an object
		/// </summary>
		/// <param name="theClass"></param>
		/// <param name="id"></param>
		/// <param name="optionalObject"></param>
		/// <param name="lockMode"></param>
		/// <param name="checkDeleted"></param>
		/// <returns></returns>
		/// <remarks>
		/// 1. see if it is already loaded
		/// 2. see if it is cached
		/// 3. actually go to the database
		/// </remarks>
		private object DoLoad( System.Type theClass, object id, object optionalObject, LockMode lockMode, bool checkDeleted )
		{
			//DONT need to flush before a load by id, because ids are constant

			if( log.IsDebugEnabled )
			{
				log.Debug( "attempting to resolve " + MessageHelper.InfoString( theClass, id ) );
			}

			IClassPersister persister = GetClassPersister( theClass );
			Key key = new Key( id, persister );

			if( optionalObject != null )
			{
				persister.SetIdentifier( optionalObject, id );
			}

			// LOOK FOR LOADED OBJECT 
			// Look for Status.Loaded object
			object old = GetEntity( key );
			if( old != null )
			{
				//if this object was already loaded
				EntityEntry oldEntry = GetEntry( old );
				Status status = oldEntry.Status;
				if( checkDeleted && ( status == Status.Deleted || status == Status.Gone ) )
				{
					throw new ObjectDeletedException( "The object with that id was deleted", id, theClass );
				}
				UpgradeLock( old, oldEntry, lockMode );
				if( log.IsDebugEnabled )
				{
					log.Debug( "resolved object in session cache " + MessageHelper.InfoString( persister, id ) );
				}
				return old;

			}
			else
			{
				// check to see if we know already that it does not exist:
				if( nonExists.Contains( key ) )
				{
					log.Debug( "entity does not exist" );
					return null;
				}

				// LOOK IN CACHE
				CacheEntry entry = persister.HasCache && lockMode.LessThan( LockMode.Read ) ?
					( CacheEntry ) persister.Cache.Get( id, Timestamp ) :
					null;

				if( entry != null )
				{
					return AssembleCacheEntry( entry, id, persister, optionalObject );
				}
				else
				{
					//GO TO DATABASE
					if( log.IsDebugEnabled )
					{
						log.Debug( "object not resolved in any cache " + MessageHelper.InfoString( persister, id ) );
					}
					object result = persister.Load( id, optionalObject, lockMode, this );
					if( result == null )
					{
						// remember it doesn't exist, in case of next time
						AddNonExist( key );
					}
					return result;
				}
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:86,代码来源:SessionImpl.cs


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