本文整理匯總了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;
}