示例#1
0
        public BetweenStructure(string text, string columnName, Interval sourceInterval, ParserRuleContext context)
        {
            BetweenPredicate tmpBetweenPredicate = new BetweenPredicate(sourceInterval, context, text);

            _text           = tmpBetweenPredicate.Text;
            _columnName     = columnName;
            _sourceInterval = sourceInterval;
        }
示例#2
0
 public void BetweenPredicate(SqlFragment parent, BetweenPredicate element)
 {
     this.Script.OpenParen();
     element.Expression.Build(parent, this);
     this.Script.Append(TSqlKeyword.BETWEEN);
     element.Minimum.Build(parent, this);
     this.Script.Append(TSqlKeyword.AND);
     element.Maximum.Build(parent, this);
     this.Script.CloseParen();
 }
            public void BetweenPredicate_ReturnsProperSql()
            {
                var pred = new BetweenPredicate<PredicateTestEntity>
                               {
                                   PropertyName = "Id",
                                   Value = new BetweenValues {Value1 = 1, Value2 = 10}
                               };

                Dictionary<string, object> parameters = new Dictionary<string, object>();
                string result = pred.GetSql(parameters);
                Assert.AreEqual("([PredicateTestEntity].[Id] BETWEEN @Id_0 AND @Id_1)", result);
                Assert.AreEqual(2, parameters.Count);
            }
        public override void EnterBetweenPredicate(MySqlParser.BetweenPredicateContext context)
        {
            if (_isOtherListener == 1)
            {
                if (context.ChildCount > 1)
                {
                    Rules.Remove(Rules[Rules.Count - 1]);
                }

                BetweenPredicate betweenPredicate =
                    new BetweenPredicate(context.SourceInterval, context, context.GetText());

                Rules.Add(betweenPredicate);
            }
            _isOtherListener++;
        }
示例#5
0
            public void BetweenPredicate_ReturnsProperSql()
            {
                var pred = new BetweenPredicate <PredicateTestEntity>
                {
                    PropertyName = "Id",
                    Value        = new BetweenValues {
                        Value1 = 1, Value2 = 10
                    }
                };

                Dictionary <string, object> parameters = new Dictionary <string, object>();
                string result = pred.GetSql(parameters);

                Assert.AreEqual("([PredicateTestEntity].[Id] BETWEEN @Id_0 AND @Id_1)", result);
                Assert.AreEqual(2, parameters.Count);
            }
        public void GetSql()
        {
            var predicate = new BetweenPredicate <TestEntity>()
            {
                Value = new BetweenValues()
                {
                    Value1 = 10,
                    Value2 = 20,
                },
                Not          = false,
                PropertyName = "Id"
            };
            var dictionary = new Dictionary <string, object>();
            var sql        = predicate.GetSql(SqlHelper.GetSqlGenerator(), dictionary);

            Assert.Equal("(Id BETWEEN @Id_0 AND @Id_1)", sql);
            Assert.Equal(10, dictionary["@Id_0"]);
            Assert.Equal(20, dictionary["@Id_1"]);
        }
 void IVisitor.VisitOnBetween(BetweenPredicate predicate, int offset)
 {
     this.ParentExists(predicate);
 }
 void IVisitor.VisitBefore(BetweenPredicate predicate)
 {
     this.ParentExists(predicate);
 }
 void IVisitor.VisitAfter(BetweenPredicate predicate)
 {
     this.ParentExists(predicate);
 }
示例#10
0
 public static ValueExpression GetMinimum(this BetweenPredicate predicate)
 {
     return(predicate.Rights[0]);
 }