本文整理汇总了C#中IQuery.SetMaxResults方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.SetMaxResults方法的具体用法?C# IQuery.SetMaxResults怎么用?C# IQuery.SetMaxResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuery
的用法示例。
在下文中一共展示了IQuery.SetMaxResults方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareQuery
/// <summary>
/// Prepare the given IQuery object, applying cache settings and/or
/// a transaction timeout.
/// </summary>
/// <param name="queryObject">The query object to prepare.</param>
public virtual void PrepareQuery(IQuery queryObject)
{
if (CacheQueries)
{
queryObject.SetCacheable(true);
if (QueryCacheRegion != null)
{
queryObject.SetCacheRegion(QueryCacheRegion);
}
}
if (FetchSize > 0)
{
AbstractQueryImpl queryImpl = queryObject as AbstractQueryImpl;
if (queryImpl != null)
{
queryImpl.SetFetchSize(FetchSize);
}
else
{
log.Warn("Could not set FetchSize for IQuery. Expected Implemention to be of type AbstractQueryImpl");
}
}
if (MaxResults > 0)
{
queryObject.SetMaxResults(MaxResults);
}
SessionFactoryUtils.ApplyTransactionTimeout(queryObject, SessionFactory);
}
示例2: SetupPaging
/// <summary>
/// Sets up NHibernate paging information if pageSize set to a number > 0.
/// </summary>
/// <param name="query">The NHibernate query.</param>
/// <param name="pageSize">The number of database records in each page. If set to 0, then this call does nothing.</param>
/// <param name="pageNumber">The 1-based page number.</param>
protected void SetupPaging(IQuery query, int pageSize, int pageNumber)
{
if (pageSize > 0)
{
query.SetMaxResults(pageSize);
query.SetFirstResult(pageSize * (pageNumber - 1));
}
}
示例3: setQueryProperties
protected void setQueryProperties(IQuery query) {
if (maxResults != null) query.SetMaxResults((int)maxResults);
if (firstResult != null) query.SetFirstResult((int)firstResult);
if (cacheable != null) query.SetCacheable((bool)cacheable);
if (cacheRegion != null) query.SetCacheRegion(cacheRegion);
if (comment != null) query.SetComment(comment);
if (flushMode != null) query.SetFlushMode(flushMode);
if (cacheMode != null) query.SetCacheMode(cacheMode);
if (timeout != null) query.SetTimeout((int)timeout);
if (lockMode != null) query.SetLockMode("e", lockMode);
}
示例4: SetQueryProperties
/// <summary>
/// Fill all <see cref="IQuery"/> properties.
/// </summary>
/// <param name="q">The <see cref="IQuery"/>.</param>
/// <remarks>
/// Query properties are overriden/merged.
/// </remarks>
protected void SetQueryProperties(IQuery q)
{
q.SetMaxResults(selection.MaxRows)
.SetFirstResult(selection.FirstRow)
.SetCacheable(cacheable)
.SetReadOnly(readOnly)
.SetTimeout(selection.Timeout)
.SetFlushMode(flushMode)
.SetFetchSize(selection.FetchSize);
if (!string.IsNullOrEmpty(comment))
q.SetComment(comment);
if (!string.IsNullOrEmpty(cacheRegion))
q.SetCacheRegion(cacheRegion);
if (resultTransformer != null)
q.SetResultTransformer(resultTransformer);
if (cacheMode.HasValue)
q.SetCacheMode(cacheMode.Value);
foreach (KeyValuePair<string, LockMode> mode in lockModes)
q.SetLockMode(mode.Key, mode.Value);
// Set AbstractQueryImpl property before set parameters
AbstractQueryImpl aqi = q as AbstractQueryImpl;
if (aqi != null)
aqi.SetIgnoreUknownNamedParameters(shouldIgnoredUnknownNamedParameters);
// Even if the probably that somebody use a mixed technique to set parameters
// (from POCO using SetProperties and using named parameter setters) here is a possible
// difference between IQuery and DetachedQuery behaviour.
// In IQuery we don't know who override a param value; in DetachedQuery the direct use of
// a named parameter setter override the param value set by SetProperties(POCO)
foreach (object obj in optionalUntypeParams)
q.SetProperties(obj);
// Set untyped positional parameters
foreach (KeyValuePair<int, object> pup in posUntypeParams)
q.SetParameter(pup.Key, pup.Value);
// Set untyped named parameters
foreach (KeyValuePair<string, object> nup in namedUntypeParams)
q.SetParameter(nup.Key, nup.Value);
// Set untyped named parameters list
foreach (KeyValuePair<string, ICollection> nulp in namedUntypeListParams)
q.SetParameterList(nulp.Key, nulp.Value);
// Set typed positional parameters
foreach (KeyValuePair<int, TypedValue> pp in posParams)
q.SetParameter(pp.Key, pp.Value.Value, pp.Value.Type);
// Set typed named parameters
foreach (KeyValuePair<string, TypedValue> np in namedParams)
q.SetParameter(np.Key, np.Value.Value, np.Value.Type);
// Set typed named parameters List
foreach (KeyValuePair<string, TypedValue> nlp in namedListParams)
q.SetParameterList(nlp.Key, (ICollection)nlp.Value.Value, nlp.Value.Type);
}
示例5: OnEvent
public void OnEvent(IQuery query)
{
query.SetMaxResults(maxResults);
}
示例6: Apply
/// <summary>
/// Applies this modifier to the query.
/// </summary>
/// <param name="query">The query</param>
public void Apply(IQuery query)
{
query.SetFirstResult(FirstResult);
query.SetMaxResults(MaxResults);
}
示例7: PrepareQueryForPagination
/// <summary>
/// For internal use only.
/// </summary>
private void PrepareQueryForPagination(IQuery query)
{
query.SetFirstResult(pageSize * (currentPage-1));
query.SetMaxResults(pageSize);
}
示例8: AddProteinMatches
/// <summary>
/// Executes the query (which must be a query on the DbProtein table), and adds
/// all of the rows in that query to the ProteinMatches.
/// </summary>
private void AddProteinMatches(IQuery query)
{
Dictionary<long, ProteinMatch> newMatches = new Dictionary<long, ProteinMatch>();
lock (this)
{
if (_matches != null)
{
foreach (var entry in _matches)
{
newMatches.Add(entry.Key, entry.Value);
}
}
}
query.SetMaxResults(MaxResults);
var newProteinIds = new List<long>();
ThrowIfCancelled();
foreach (DbProtein dbProtein in query.Enumerable())
{
ThrowIfCancelled();
if (!dbProtein.Id.HasValue || newMatches.ContainsKey(dbProtein.Id.Value))
{
continue;
}
newProteinIds.Add(dbProtein.Id.Value);
}
if (newProteinIds.Count == 0)
{
return;
}
// We fetched the protein ids. Now fetch all the protein rows themselves.
var newProteins = new List<DbProtein>();
_session.CreateCriteria(typeof (DbProtein))
.Add(Restrictions.In("Id", newProteinIds)) // Not L10N
.List(newProteins);
// Now fetch all of the protein name records at once
var criteria = _session.CreateCriteria(typeof (DbProteinName))
.Add(Restrictions.In("Protein", newProteins)); // Not L10N
var proteinNames = new Dictionary<DbProtein, List<DbProteinName>>();
foreach (DbProteinName proteinName in criteria.List())
{
List<DbProteinName> names;
if (!proteinNames.TryGetValue(proteinName.Protein, out names))
{
names = new List<DbProteinName>();
proteinNames.Add(proteinName.Protein, names);
}
names.Add(proteinName);
}
// Create a ProteinMatch for each Protein
foreach (var entry in proteinNames)
{
var proteinMatch = new ProteinMatch(Settings, new Protein(Settings.ProteomeDbPath, entry.Key, entry.Value));
if (entry.Key.Id.HasValue)
newMatches.Add(entry.Key.Id.Value, proteinMatch);
}
SetProteinMatches(newMatches);
}
示例9: commonPrepare
private void commonPrepare(IQuery q){
if (query.MaxCount != 0){
q.SetMaxResults(query.MaxCount);
}
if (query.StartIndex != 0){
q.SetFirstResult(query.StartIndex);
}
}