Ejemplo n.º 1
0
        private INoDataQuery <TDto> buildQuery(IQueryable <TDto> sourceQueryable, QueryParser <TDto> parser)
        {
            var filterExpr    = parser.ApplyFilterExpression(ParameterDtoExpression);
            var selectionTree = Utility.SchemaToQueryable.TranslateTree2(parser.SelectionTree, parser.SelectPaths);

            // security: check max expand
            if (Settings.MaxExpandDepth >= 0)
            {
                var paths = selectionTree.EnumerateAllPaths();
                if (paths.Any(x => x.Count() > Settings.MaxExpandDepth))
                {
                    throw new ArgumentException("Cannot expand past the max expand depth of: " + Settings.MaxExpandDepth);
                }
            }

            var selectExpandExpression = Utility.ExpressionBuilder.GetExpandExpression(ParameterDtoExpression, selectionTree, GraphSchema.CacheInstance);

            return(new NoDataQuery <TDto>(sourceQueryable, Parameters, GraphSchema.CacheInstance, parser.OrderByPath, selectExpandExpression, filterExpr, ParameterDtoExpression, selectionTree));
        }