Пример #1
0
 protected virtual void EmitBetween(NPathBetweenExpression betweenExpression)
 {
     EmitExpression(betweenExpression.TestExpression);
     Write(" between "); // do not localize
     EmitExpression(betweenExpression.FromExpression);
     Write(" and "); // do not localize
     EmitExpression(betweenExpression.EndExpression);
 }
Пример #2
0
		private SqlExpression EvalBetween(NPathBetweenExpression betweenExpression)
		{
			SqlSearchCondition search ;
			
			if (noNext)
				search = conditionChainOwner as SqlSearchCondition ; 
			else
				search = conditionChainOwner.GetNextSqlSearchCondition() ; 
			noNext = false;

			SqlExpression leftExpression = EvalExpression(betweenExpression.TestExpression );
			SqlExpression middleExpression = EvalExpression(betweenExpression.FromExpression);
			SqlExpression rightExpression = EvalExpression(betweenExpression.EndExpression);
			
			SqlPredicate predicate = search.GetSqlBetweenPredicate(leftExpression, middleExpression ,rightExpression) ;									
			return predicate;
		}
        protected virtual bool EvalBetweenExpression(object item, NPathBetweenExpression betweenExpression)
        {
            object fromValue = EvalValue(item, betweenExpression.FromExpression);
            object endValue = EvalValue(item, betweenExpression.EndExpression);
            object testValue = EvalValue(item, betweenExpression.TestExpression);

            if (fromValue is string)
                fromValue = fromValue.ToString().ToLower();

            if (endValue is string)
                endValue = endValue.ToString().ToLower();

            if (testValue is string)
                testValue = testValue.ToString().ToLower();

            int res1 = Comparer.DefaultInvariant.Compare(testValue, fromValue);
            if (res1 < 0)
                return false;

            int res2 = Comparer.DefaultInvariant.Compare(testValue, endValue);

            if (res2 > 0)
                return false;

            return true;
        }
Пример #4
0
        private IValue ParseBetweenExpression(IValue leftOperand)
        {
            NPathBetweenExpression between = new NPathBetweenExpression();
            between.TestExpression = leftOperand;

            tokenizer.GetCurrentToken("between", "Between");
            tokenizer.MoveNext();

            if (CurrentIsValue())
                between.FromExpression = ParseExpression();
            else
                throw GetExpectedTokenException("Value");

            tokenizer.GetCurrentToken("and", "And");
            tokenizer.MoveNext();

            if (CurrentIsValue())
                between.EndExpression = ParseExpression();
            else
                throw GetExpectedTokenException("Value");

            return between;
        }