protected ActionResult CacheableView(string viewName, Query.Query query, Func<ModelCollection> modelAccessor, Action<OutputCacheParameters> changeSettings)
        {
            if (query.IsCacheable)
            {
                var settings = new OutputCacheParameters
                {
                    Duration = query.CacheDuration,
                    VaryByParam = null,
                    VaryByContentEncoding = null,
                    VaryByControl = null,
                    VaryByCustom = null,
                    VaryByHeader = null
                };

                changeSettings(settings);

                return new CacheableViewResult
                {
                    ViewName = viewName,
                    ViewData = ViewData,
                    TempData = TempData,
                    ModelAccessor = modelAccessor,
                    CacheSettings = settings
                };
            }
            return View(viewName, modelAccessor());
        }
 public static Query Parse(Type modelType, IQueryable source, QueryAttribute attr)
 {
     var query = new Query(modelType, source);
     if (attr != null)
     {
         query.Select = ParseSelect(modelType, attr);
         query.Where = ParseWhere(attr);
         query.OrderBy = ParseOrderBy(modelType, attr);
         query.Skip = ParseSkip(attr);
         query.Take = ParseTake(attr);
         query.CacheDuration = attr.CacheDuration;
         query.Include = attr.Include;
         query.Parameters = attr.Parameters;
         query.Paging = attr.Paging;
         query.PageSize = attr.PageSize > 0 ? attr.PageSize : Query.DefaultPageSize;
         query.Id = attr.Id;
     }
     else
         query.IsEmpty = true;
     return query;
 }
        internal void ParseKeywords(Query query)
        {
            foreach (var evaluator in KeywordEvaluators)
            {
                var value = evaluator.Value(query);

                if (query.Where.Expression.Contains(evaluator.Key))
                {
                    var parameterName = string.Format("@{0}", query.Parameters.Length);
                    query.Where.Expression = query.Where.Expression.Replace(evaluator.Key, parameterName);
                    var parameters = new List<object>(query.Parameters) {value};
                    query.Parameters = parameters.ToArray();
                }

                for (var i = 0; i < query.Parameters.Length; i++)
                {
                    var parameter = query.Parameters[i];
                    if (parameter != null && parameter.ToString() == evaluator.Key)
                        query.Parameters[i] = value;
                }
            }
        }