示例#1
0
        public FilterDefinition <T> RenderCollection(LinkedListNode <QueryNode> queryNodeItem)
        {
            var queryNode = queryNodeItem.Value;

            queryNode.ConvertPivotToCriterias();

            var pathToCollection = new List <string>(queryNodeItem.GetPathFromRoot(includeRoot: true));

            // TODO: Find better way
            pathToCollection = pathToCollection.ConvertForMongo();

            var resultingFilter = RenderCriteriaGroup(queryNode, pathToCollection);

            return(resultingFilter);
        }
示例#2
0
        public IFindFluent <T, T> RenderMethod(LinkedListNode <QueryNode> queryNodeItem, IFindFluent <T, T> mongoQuery)
        {
            var queryNode = queryNodeItem.Value;
            var result    = mongoQuery;

            switch (queryNode.MethodType)
            {
            case QueryMethodType.Set:
            case QueryMethodType.Add:
            case QueryMethodType.Get:
            case QueryMethodType.Delete:
            case QueryMethodType.ToMd:
            case QueryMethodType.ToT:
            case QueryMethodType.ToLocal:
                break;

            case QueryMethodType.Take:
                result = result.Limit(Convert.ToInt32(queryNode.Arguments.First().ArgumentValueConstant));
                break;

            case QueryMethodType.Skip:
                result = result.Skip(Convert.ToInt32(queryNode.Arguments.First().ArgumentValueConstant));
                break;

            case QueryMethodType.OrderBy:
            {
                foreach (var argument in queryNode.Arguments)
                {
                    var pathFromRoot = queryNodeItem.GetPathFromRoot(true);
                    pathFromRoot.AddRange(argument.ArgumentValueQuery.NodesList.Last.GetPathFromRoot(true));

                    result = result.Sort(Builders <T> .Sort.Ascending(string.Join(".", pathFromRoot.ConvertForMongo())));
                }
            }
            break;

            case null:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(result);
        }