private LucQuery() { TraceInfo = new QueryTraceInfo(); }
private static InnerQueryResult ExecuteInnerScript(string src, int top, int skip, IEnumerable <SortInfo> sort, FilterStatus enableAutofilters, FilterStatus enableLifespanFilter, QuerySettings settings, bool enableProjection, out int count, out QueryTraceInfo traceInfo) { LucQuery query; try { query = LucQuery.Parse(src); } catch (ParserException ex) { throw new InvalidContentQueryException(src, innerException: ex); } var projection = query.Projection; if (projection != null) { if (!enableProjection) { throw new ApplicationException(String.Format("Projection in top level query is not allowed ({0}:{1})", Parser.SnLucLexer.Keywords.Select, projection)); } } if (skip != 0) { query.Skip = skip; } if (top != 0) { query.PageSize = top; } else if (query.PageSize == 0) { query.PageSize = GetDefaultMaxResults(); } if (sort != null && sort.Count() > 0) { query.SetSort(sort); } if (enableAutofilters != FilterStatus.Default) { query.EnableAutofilters = enableAutofilters; } if (enableLifespanFilter != FilterStatus.Default) { query.EnableLifespanFilter = enableLifespanFilter; } //Re-set settings values. This is important for NodeList that //uses the paging info written into the query text. if (settings != null) { settings.Top = query.PageSize; settings.Skip = query.Skip; } InnerQueryResult result; var qresult = query.Execute().ToList(); if (projection == null || !enableProjection) { var idResult = qresult.Select(o => o.NodeId).ToArray(); result = new InnerQueryResult { IsIntArray = true, IntArray = idResult, StringArray = idResult.Select(i => i.ToString()).ToArray() }; } else { var stringResult = qresult.Select(o => o[projection, false]).Where(r => !String.IsNullOrEmpty(r)); var escaped = new List <string>(); foreach (var s in stringResult) { escaped.Add(EscapeForQuery(s)); } result = new InnerQueryResult { IsIntArray = false, StringArray = escaped.ToArray() }; } traceInfo = query.TraceInfo; count = query.TotalCount; return(result); }