Beispiel #1
0
        public IList <MediaCategory> GetSubFolders(MediaCategorySearchModel searchModel)
        {
            IQueryOver <MediaCategory, MediaCategory> queryOver =
                _session.QueryOver <MediaCategory>().Where(x => !x.HideInAdminNav);

            queryOver = searchModel.Id.HasValue
                ? queryOver.Where(x => x.Parent.Id == searchModel.Id)
                : queryOver.Where(x => x.Parent == null);
            if (!string.IsNullOrWhiteSpace(searchModel.SearchText))
            {
                queryOver =
                    queryOver.Where(
                        category => category.Name.IsInsensitiveLike(searchModel.SearchText, MatchMode.Anywhere));
            }

            queryOver = queryOver.OrderBy(searchModel.SortBy);

            return(queryOver.Cacheable().List());
        }
 private void CopyCriteriaValues(CriteriaImpl criteria, IQueryOver <TRoot, TRoot> query)
 {
     if (!string.IsNullOrEmpty(criteria.CacheRegion))
     {
         query.CacheRegion(criteria.CacheRegion);
     }
     if (criteria.Cacheable)
     {
         query.Cacheable();
     }
     if (criteria.IsReadOnly)
     {
         query.ReadOnly();
     }
     foreach (var pair in criteria.LockModes)
     {
         query.UnderlyingCriteria.SetLockMode(pair.Key, pair.Value);
     }
     if (criteria.Timeout != RowSelection.NoValue)
     {
         query.UnderlyingCriteria.SetTimeout(criteria.Timeout);
     }
 }
 public IQueryOver <TRoot> Cacheable()
 {
     MainQuery.Cacheable();
     return(this);
 }
 private static int GetRowCount(IQueryOver <Webpage, Webpage> query)
 {
     return(query.Cacheable().RowCount());
 }
Beispiel #5
0
 public static IQueryOver <TQuery> MakeCacheable <TQuery>(this IQueryOver <TQuery> query, bool enableCache = true)
 {
     return(enableCache ? query.Cacheable() : query);
 }