示例#1
0
        public bool Enter(
            FilterOperationField field,
            ObjectFieldNode node,
            IQueryableFilterVisitorContext context,
            out ISyntaxVisitorAction action)
        {
            if (field.Operation.Kind == FilterOperationKind.ArraySome ||
                field.Operation.Kind == FilterOperationKind.ArrayNone ||
                field.Operation.Kind == FilterOperationKind.ArrayAll)
            {
                MemberExpression nestedProperty = Expression.Property(
                    context.GetInstance(),
                    field.Operation.Property);

                context.PushInstance(nestedProperty);

                Type closureType = GetTypeFor(field.Operation);

                context.AddClosure(closureType);
                action = SyntaxVisitor.Continue;
                return(true);
            }
            action = SyntaxVisitor.Skip;
            return(false);
        }
示例#2
0
 public bool Enter(
     FilterOperationField field,
     ObjectFieldNode node,
     IQueryableFilterVisitorContext context,
     out ISyntaxVisitorAction action)
 {
     if (field.Operation.Kind == FilterOperationKind.Object)
     {
         MemberExpression nestedProperty = Expression.Property(
             context.GetInstance(),
             field.Operation.Property);
         context.PushInstance(nestedProperty);
         action = SyntaxVisitor.Continue;
         return(true);
     }
     action = SyntaxVisitor.SkipAndLeave;
     return(false);
 }
        public static bool Enter(
            FilterOperationField field,
            ObjectFieldNode node,
            IQueryableFilterVisitorContext context,
            [NotNullWhen(true)] out ISyntaxVisitorAction?action)
        {
            if (node.Value.IsNull())
            {
                if (field.Operation.IsNullable)
                {
                    MemberExpression nestedProperty = Expression.Property(
                        context.GetInstance(),
                        field.Operation.Property);

                    Expression expression =
                        FilterExpressionBuilder.Equals(nestedProperty, null !);

                    context.GetLevel().Enqueue(expression);
                }
                else
                {
                    context.ReportError(
                        ErrorHelper.CreateNonNullError(field, node, context));
                }

                action = SyntaxVisitor.Skip;
                return(true);
            }

            if (field.Operation.Kind == FilterOperationKind.Object)
            {
                MemberExpression nestedProperty = Expression.Property(
                    context.GetInstance(),
                    field.Operation.Property);

                context.PushInstance(nestedProperty);
                action = SyntaxVisitor.Continue;
                return(true);
            }
            action = null;
            return(false);
        }
示例#4
0
        public static bool Enter(
            FilterOperationField field,
            ObjectFieldNode node,
            IQueryableFilterVisitorContext context,
            [NotNullWhen(true)] out ISyntaxVisitorAction?action)
        {
            if (field.Operation.Kind == FilterOperationKind.ArraySome ||
                field.Operation.Kind == FilterOperationKind.ArrayNone ||
                field.Operation.Kind == FilterOperationKind.ArrayAll)
            {
                if (!field.Operation.IsNullable && node.Value.IsNull())
                {
                    context.ReportError(
                        ErrorHelper.CreateNonNullError(field, node, context));

                    action = SyntaxVisitor.Skip;
                    return(true);
                }

                MemberExpression nestedProperty = Expression.Property(
                    context.GetInstance(),
                    field.Operation.Property);

                context.PushInstance(nestedProperty);

                Type closureType = GetTypeFor(field.Operation);

                if (node.Value.IsNull())
                {
                    context.AddIsNullClosure(closureType);
                    action = SyntaxVisitor.SkipAndLeave;
                }
                else
                {
                    context.AddClosure(closureType);
                    action = SyntaxVisitor.Continue;
                }
                return(true);
            }
            action = null;
            return(false);
        }