Ejemplo n.º 1
0
        public static bool NotContains(
            FilterOperation operation,
            IInputType type,
            IValueNode value,
            IQueryableFilterVisitorContext context,
            [NotNullWhen(true)] out Expression?result)
        {
            object parsedValue = type.ParseLiteral(value);

            if (parsedValue == null)
            {
                context.ReportError(
                    ErrorHelper.CreateNonNullError(operation, type, value, context));

                result = null;
                return(false);
            }

            if (operation.Type == typeof(string) &&
                type.IsInstanceOfType(value))
            {
                Expression property = GetProperty(operation, context);

                result = FilterExpressionBuilder.NotContains(property, parsedValue);
                return(true);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Ejemplo n.º 2
0
        protected override bool TryCreateExpression(
            FilterOperation operation,
            Expression property,
            object parsedValue,
            [NotNullWhen(true)] out Expression?expression)
        {
            switch (operation.Kind)
            {
            case FilterOperationKind.Contains:
                expression = FilterExpressionBuilder.Contains(
                    property, parsedValue);
                return(true);

            case FilterOperationKind.NotContains:
                expression = FilterExpressionBuilder.NotContains(
                    property, parsedValue);
                return(true);

            default:
                expression = null;
                return(false);
            }
        }