public void GetNext()
        {
            var parameter = new ExpressionParameters();

            parameter.Next().Should().Be("a");
            parameter.Next().Should().Be("b");
        }
Exemplo n.º 2
0
        public Expression <Func <TEntity, dynamic> > CreateExpression()
        {
            var operationDefinition = _queryDocument.Document.Definitions.FirstOrDefault() as OperationDefinitionNode;

            if (operationDefinition.Operation == OperationType.Subscription)
            {
                throw new UnsupportedOperationException(operationDefinition.Operation);
            }

            var fieldNode = operationDefinition.SelectionSet.Selections.FirstOrDefault() as FieldNode;

            var parameter = Expression.Parameter(typeof(TEntity), _expressionParameters.Next());

            var newExpression = CreateNewExpression(fieldNode, typeof(TEntity), parameter);

            return(Expression.Lambda <Func <TEntity, dynamic> >(newExpression, parameter));
        }
        public Expression <Func <TEntity, dynamic> > CreateExpression <TSchema>(params string[] filters)
        {
            var operationDefinition = _queryDocument.Document.Definitions.FirstOrDefault() as OperationDefinitionNode;

            if (operationDefinition.Operation == OperationType.Subscription)
            {
                throw new UnsupportedOperationException(operationDefinition.Operation);
            }

            var fieldNode = operationDefinition
                            .SelectionSet
                            .Selections
                            .Cast <FieldNode>()
                            .FirstOrDefault(s => !filters.Any(f => s.Name.Kind.ToString() == f));

            var parameter = Expression.Parameter(typeof(TEntity), _expressionParameters.Next());

            var newExpression = CreateNewExpression(fieldNode, typeof(TEntity), typeof(TSchema), parameter, filters);

            return(Expression.Lambda <Func <TEntity, dynamic> >(newExpression, parameter));
        }