Ejemplo n.º 1
0
 public void OpenContext(ConvertedExpression expression, BinaryExpression node)
 {
     if (!SupportedMethods.Contains((expression.Equality ?? string.Empty).TrimStart(ExpressionType.Not.ToString().ToCharArray())))
         return;
     _contexts.Add(new SubQueryContext { Target = expression.Target,
                                         ContextKey = node.ToString(),
                                         // ReSharper disable PossibleNullReferenceException
                                         NegateContext = expression.Equality.StartsWith(ExpressionType.Not.ToString())
                                         // ReSharper restore PossibleNullReferenceException
     });
 }
Ejemplo n.º 2
0
        internal bool SetContext(ConvertedExpression currentExpression)
        {
            if(!_contexts.Any()) {
                return false;
            }

            currentExpression.Target = _contexts.Last().Target;

            //if it starts with dual "NotNot" its a Not inside the Not context, i guess its an equal then ?
            if (_contexts.Last().NegateContext && currentExpression.Equality.StartsWith(ExpressionType.Not + ExpressionType.Not.ToString())) {
                currentExpression.Equality =
                    currentExpression.Equality.TrimStart((ExpressionType.Not.ToString() + ExpressionType.Not).ToCharArray());
            }
            else if (_contexts.Last().NegateContext && !currentExpression.Equality.StartsWith(ExpressionType.Not.ToString())) {
                currentExpression.Equality = ExpressionType.Not + currentExpression.Equality;
            }

            return true;
        }