本文整理汇总了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;
}