本文整理汇总了C#中IQuery.SetCacheable方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.SetCacheable方法的具体用法?C# IQuery.SetCacheable怎么用?C# IQuery.SetCacheable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuery
的用法示例。
在下文中一共展示了IQuery.SetCacheable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: OnEvent
public void OnEvent(IQuery query)
{
query.SetCacheable(cacheable);
}
示例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: InitSession
/// <summary>
/// Initializes the session that will be used to enumerate
/// </summary>
private void InitSession()
{
_session = _sessionFactory.OpenSession();
_session.FlushMode = FlushMode.Never;
_tx = _session.BeginTransaction();
try
{
//Handle the case of entity type (InitialLoad)
if (_entityType != null)
{
_criteria = _session.CreateCriteria(_entityType);
_criteria.SetCacheable(false);
//If perform by id, add order to the criteria
if (_performOrderById)
{
IClassMetadata metadata = _sessionFactory.GetClassMetadata(_entityType);
string idPropName = metadata.IdentifierPropertyName;
if (idPropName != null)
_criteria.AddOrder(Order.Asc(idPropName));
}
}
//Handle the case of Persistency.Query (GetEnumerator)
else if (_persistencyQuery != null)
{
string select = _persistencyQuery.SqlQuery;
_query = _session.CreateQuery(select);
object[] preparedValues = _persistencyQuery.Parameters;
if (preparedValues != null)
{
for (int i = 0; i < preparedValues.Length; i++)
{
_query.SetParameter(i, preparedValues[i]);
}
}
_query.SetCacheable(false);
_query.SetFlushMode(FlushMode.Never);
}
else throw new Exception("NHibernateDataEnumerator must receive an Entity Type or a Query");
}
catch(Exception ex)
{
if (_tx != null && _tx.IsActive)
_tx.Rollback();
if (_session.IsOpen)
_session.Close();
throw new Exception("Error while constructing an enumerator", ex);
}
}
开发者ID:GigaSpaces-ProfessionalServices,项目名称:xapnet-templates,代码行数:51,代码来源:NHibernateDataEnumerator.cs