public FilterDefinition <T> RenderQueryFilter(SingleQuery query) { query = query.MakeCopy(); // Convert Id to masterId if needed query.ConvertIdToMasterId(); var filters = new List <FilterDefinition <T> >(); for (var queryNodeItem = query.NodesList.First; queryNodeItem != null; queryNodeItem = queryNodeItem.Next) { var queryNode = queryNodeItem.Value; if (queryNode.Type != QueryNodeType.Collection) { continue; } var collectionFilter = RenderCollection(queryNodeItem); filters.Add(collectionFilter); } var resultingFilter = filters.Any() ? filters.Aggregate((a, b) => a & b) : this.filterBuilder.Empty; return(resultingFilter); }
public IQueryable <JToken> ExecuteQuery(SingleQuery query, IQueryable <JToken> source, ExpandoObject services) { query = query.MakeCopy(); // Convert Id to masterId if needed query.ConvertIdToMasterId(); initialDataSource = source; eData = source; var result = initialDataSource; for (var queryNodeItem = query.NodesList.First; queryNodeItem != null; queryNodeItem = queryNodeItem.Next) { var queryNode = queryNodeItem.Value; // BelongsTo workaround queryNode.BelongsToQuery = query; // For root node if (queryNode.RootType.HasValue) { switch (queryNode.RootType) { case QueryRootType.Variable: var variable = ((dynamic)services).Variables[queryNode.Name]; if (variable is JToken) { initialDataSource = new[] { (JToken)variable } } .AsQueryable(); else { initialDataSource = ((IEnumerable <JToken>)variable).AsQueryable(); } break;