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


C# IQuery.SetCacheable方法代码示例

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

        }
开发者ID:fuadm,项目名称:spring-net,代码行数:37,代码来源:HibernateAccessor.cs

示例2: OnEvent

 public void OnEvent(IQuery query)
 {
     query.SetCacheable(cacheable);
 }
开发者ID:spib,项目名称:nhcontrib,代码行数:4,代码来源:SetCacheableEvent.cs

示例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);
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:11,代码来源:AbstractAuditQuery.cs

示例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


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