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


C# QueryParameters.CreateCopyUsing方法代码示例

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


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

示例1: List

		public IList List(ISessionImplementor session, QueryParameters queryParameters)
		{
			// Delegate to the QueryLoader...
			ErrorIfDML();
			var query = ( QueryNode ) _sqlAst;
			bool hasLimit = queryParameters.RowSelection != null && queryParameters.RowSelection.DefinesLimits;
			bool needsDistincting = ( query.GetSelectClause().IsDistinct || hasLimit ) && ContainsCollectionFetches;

			QueryParameters queryParametersToUse;

			if ( hasLimit && ContainsCollectionFetches ) 
			{
				log.Warn( "firstResult/maxResults specified with collection fetch; applying in memory!" );
				var selection = new RowSelection
				                         	{
				                         		FetchSize = queryParameters.RowSelection.FetchSize,
				                         		Timeout = queryParameters.RowSelection.Timeout
				                         	};
				queryParametersToUse = queryParameters.CreateCopyUsing( selection );
			}
			else 
			{
				queryParametersToUse = queryParameters;
			}

			IList results = _queryLoader.List(session, queryParametersToUse);

			if ( needsDistincting ) 
			{
				int includedCount = -1;
				// NOTE : firstRow is zero-based
				int first = !hasLimit || queryParameters.RowSelection.FirstRow == RowSelection.NoValue
							? 0
							: queryParameters.RowSelection.FirstRow;
				int max = !hasLimit || queryParameters.RowSelection.MaxRows == RowSelection.NoValue
							? -1
							: queryParameters.RowSelection.MaxRows;

				int size = results.Count;
				var tmp = new List<object>();
				var distinction = new IdentitySet();

				for ( int i = 0; i < size; i++ ) 
				{
					object result = results[i];
					if ( !distinction.Add(result ) ) 
					{
						continue;
					}
					includedCount++;
					if ( includedCount < first ) 
					{
						continue;
					}
					tmp.Add( result );
					// NOTE : ( max - 1 ) because first is zero-based while max is not...
					if ( max >= 0 && ( includedCount - first ) >= ( max - 1 ) ) 
					{
						break;
					}
				}

				results = tmp;
			}

			return results;
		}
开发者ID:paulbatum,项目名称:nhibernate,代码行数:67,代码来源:QueryTranslatorImpl.cs


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