Exemplo n.º 1
0
        protected static ProcessResult CreateResult(ActionContext context, IQueryable query, int?takeCount, IQueryable inlineCountQuery)
        {
            int?max = context.MaxResultCount ?? context.Service?.MaxResultCount;

            if (max > 0)
            {
                var count = takeCount ?? Queryable.Count((dynamic)query);
                if (count > max)
                {
                    throw new Exception($"Maximum allowed read count exceeded");
                }
            }

            var service = context.Service;

            if (service == null)
            {
                return(CreateResult(context, Enumerable.ToList((dynamic)query), inlineCountQuery));
            }

            var beforeArgs = new BeforeQueryEventArgs(context, query);

            service.OnBeforeQueryExecute(beforeArgs);
            query = beforeArgs.Query;

            var result    = Enumerable.ToList((dynamic)query);
            var afterArgs = new AfterQueryEventArgs(context, query, result);

            service.OnAfterQueryExecute(afterArgs);
            result = afterArgs.Result;

            return(CreateResult(context, result, inlineCountQuery));
        }
Exemplo n.º 2
0
 void ILinquestService.OnAfterQueryExecute(AfterQueryEventArgs args)
 => AfterQueryExecute?.Invoke(this, args);