コード例 #1
0
 public void ShouldCreateAddExpression()
 {
     var factory = new DbExpressionFactory();
     DbBinaryExpression binaryExpression;
     binaryExpression = factory.Add(factory.Constant(1), factory.Constant(2));
     ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Add);
 }
コード例 #2
0
        public void ShouldCreateAssignmentExpression()
        {
            var factory = new DbExpressionFactory();
            DbBinaryExpression binaryExpression;

            binaryExpression = factory.Assign(factory.Constant(1), factory.Constant(2));
            ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Assignment);
        }
コード例 #3
0
        public void ShouldCreateLessThanOrEqualExpression()
        {
            var factory = new DbExpressionFactory();
            DbBinaryExpression binaryExpression;

            binaryExpression = factory.LessThanOrEqual(factory.Constant(1), factory.Constant(2));
            ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.LessThanOrEqual);
        }
コード例 #4
0
        public void ShouldCreateOrExpression()
        {
            var factory = new DbExpressionFactory();
            DbBinaryExpression binaryExpression;

            binaryExpression = factory.Or(factory.Constant(1), factory.Constant(2));
            ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Or);
        }
コード例 #5
0
        public void ShouldCreateSubstractExpression()
        {
            var factory = new DbExpressionFactory();
            DbBinaryExpression binaryExpression;

            binaryExpression = factory.Subtract(factory.Constant(1), factory.Constant(2));
            ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Subtract);
        }
コード例 #6
0
        public void ShouldCreateConcatExpression()
        {
            var factory    = new DbExpressionFactory();
            var expression = factory.Concat(factory.Constant("DummyExpression"),
                                            factory.Constant("AnotherDummyExpression"));

            Assert.IsNotNull(expression.LeftExpression);
            Assert.IsNotNull(expression.RightExpression);
            Assert.IsTrue(expression.ExpressionType == DbExpressionType.Concat);
        }
コード例 #7
0
        public void ShouldCreateConditionalExpression()
        {
            var factory    = new DbExpressionFactory();
            var expression = factory.Conditional(factory.Column("SomeColumn") == factory.Constant("SomeValue"),
                                                 factory.Constant("ValueWhenTrue"), factory.Constant("ValueWhenFalse"));

            Assert.IsNotNull(expression.Condition);
            Assert.IsNotNull(expression.IfFalse);
            Assert.IsNotNull(expression.IfTrue);
            Assert.IsTrue(expression.ExpressionType == DbExpressionType.Conditional);
        }
コード例 #8
0
 public void ShouldCreateAddMinutesExpression()
 {
     var factory = new DbExpressionFactory();
     DbDateTimeFunctionExpression dateTimeFunctionExpression;
     dateTimeFunctionExpression = factory.AddMinutes(factory.Column("SomeDateTimeColumn"), factory.Constant(2));
     ValidateDateTimeFunctionExpression(dateTimeFunctionExpression, DbDateTimeFunctionExpressionType.AddMinutes);
 }
コード例 #9
0
        public void ShouldCreateContantExpression()
        {
            var factory    = new DbExpressionFactory();
            var expression = factory.Constant("SomeValue");

            Assert.IsNotNull(expression.Value);
            Assert.IsTrue(expression.ExpressionType == DbExpressionType.Constant);
        }
コード例 #10
0
 public void ShouldCreateSubstractExpression()
 {
     var factory = new DbExpressionFactory();
     DbBinaryExpression binaryExpression;
     binaryExpression = factory.Subtract(factory.Constant(1), factory.Constant(2));
     ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Subtract);
 }
コード例 #11
0
 /// <summary>
 /// Specifies the column to be updated.
 /// </summary>
 /// <param name="dbUpdateQuery">The target <see cref="DbQuery{TQueryExpression}"/>.</param>
 /// <param name="columnSelector">A function used to specify the column to be updated.</param>
 /// <param name="value">The new value.</param>
 /// <returns><see cref="DbQuery{TQueryExpression}"/></returns>
 public static DbQuery <DbUpdateExpression> Set(this DbQuery <DbUpdateExpression> dbUpdateQuery, Func <DbExpressionFactory, DbExpression> columnSelector, object value)
 {
     return(Set(dbUpdateQuery, columnSelector(DbExpressionFactory), DbExpressionFactory.Constant(value)));
 }
コード例 #12
0
        public void ShouldCreateAddMillisecondsExpression()
        {
            var factory = new DbExpressionFactory();
            DbDateTimeFunctionExpression dateTimeFunctionExpression;

            dateTimeFunctionExpression = factory.AddMilliseconds(factory.Column("SomeDateTimeColumn"), factory.Constant(2));
            ValidateDateTimeFunctionExpression(dateTimeFunctionExpression, DbDateTimeFunctionExpressionType.AddMilliseconds);
        }
コード例 #13
0
 public void ShouldCreateConditionalExpression()
 {
     var factory = new DbExpressionFactory();
     var expression = factory.Conditional(factory.Column("SomeColumn") == factory.Constant("SomeValue"),
                         factory.Constant("ValueWhenTrue"), factory.Constant("ValueWhenFalse"));
     Assert.IsNotNull(expression.Condition);
     Assert.IsNotNull(expression.IfFalse);
     Assert.IsNotNull(expression.IfTrue);
     Assert.IsTrue(expression.ExpressionType == DbExpressionType.Conditional);
 }
コード例 #14
0
 public void ShouldCreateConcatExpression()
 {
     var factory = new DbExpressionFactory();
     var expression = factory.Concat(factory.Constant("DummyExpression"),
                                     factory.Constant("AnotherDummyExpression"));
     Assert.IsNotNull(expression.LeftExpression);
     Assert.IsNotNull(expression.RightExpression);
     Assert.IsTrue(expression.ExpressionType == DbExpressionType.Concat);
 }
コード例 #15
0
        public void ShouldCreateSubStringExpression()
        {
            var factory = new DbExpressionFactory();
            var stringFunctionExpression = factory.SubString(factory.Column("SomeStringColumn"), factory.Constant(1), factory.Constant(2));

            ValidateStringFunctionExpression(stringFunctionExpression, DbStringFunctionExpressionType.SubString);
        }
コード例 #16
0
 public void ShouldCreateContantExpression()
 {
     var factory = new DbExpressionFactory();
     var expression = factory.Constant("SomeValue");
     Assert.IsNotNull(expression.Value);
     Assert.IsTrue(expression.ExpressionType == DbExpressionType.Constant);
 }
コード例 #17
0
 public void ShouldCreateGreaterThanExpression()
 {
     var factory = new DbExpressionFactory();
     DbBinaryExpression binaryExpression;
     binaryExpression = factory.GreaterThan(factory.Constant(1), factory.Constant(2));
     ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.GreaterThan);
 }
コード例 #18
0
        public void ShouldCreateReplaceExpression()
        {
            var factory = new DbExpressionFactory();
            var stringFunctionExpression = factory.Replace(factory.Column("SomeStringColumn"), factory.Constant("OldValue"), factory.Constant("NewValue"));

            ValidateStringFunctionExpression(stringFunctionExpression, DbStringFunctionExpressionType.Replace);
        }
コード例 #19
0
 public void ShouldCreateSubStringExpression()
 {
     var factory = new DbExpressionFactory();
     var stringFunctionExpression = factory.SubString(factory.Column("SomeStringColumn"), factory.Constant(1), factory.Constant(2));
     ValidateStringFunctionExpression(stringFunctionExpression, DbStringFunctionExpressionType.SubString);
 }
コード例 #20
0
 public void ShouldCreateNotEqualExpression()
 {
     var factory = new DbExpressionFactory();
     DbBinaryExpression binaryExpression;
     binaryExpression = factory.NotEqual(factory.Constant(1), factory.Constant(2));
     ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.NotEqual);
 }
コード例 #21
0
 /// <summary>
 /// Limits the numbers of rows returned by the query.
 /// </summary>
 /// <param name="dbSelectQuery">The target <see cref="DbQuery{TQueryExpression}"/>.</param>
 /// <param name="count">The number of rows to return.</param>
 /// <returns><see cref="DbQuery{TQueryExpression}"/></returns>
 public static DbQuery <DbSelectExpression> Take(this DbQuery <DbSelectExpression> dbSelectQuery, int count)
 {
     dbSelectQuery.QueryExpression.TakeExpression = DbExpressionFactory.Constant(count);
     return(dbSelectQuery);
 }
コード例 #22
0
        public void ShouldCreateRandWithSeedExpression()
        {
            var factory = new DbExpressionFactory();
            DbMathematicalFunctionExpression mathematicalFunctionExpression = factory.Rand(factory.Constant(10));

            ValidateMathematicalFunctionExpression(mathematicalFunctionExpression, DbMathematicalFunctionExpressionType.RandSeed);
        }
コード例 #23
0
 public void ShouldCreateRoundExpression()
 {
     var factory = new DbExpressionFactory();
     DbMathematicalFunctionExpression mathematicalFunctionExpression = factory.Round(factory.Column("SomeColumn"), factory.Constant(2));
     ValidateMathematicalFunctionExpression(mathematicalFunctionExpression, DbMathematicalFunctionExpressionType.Round);
 }
コード例 #24
0
 public void ShouldCreateReplaceExpression()
 {
     var factory = new DbExpressionFactory();
     var stringFunctionExpression = factory.Replace(factory.Column("SomeStringColumn"), factory.Constant("OldValue"), factory.Constant("NewValue"));
     ValidateStringFunctionExpression(stringFunctionExpression, DbStringFunctionExpressionType.Replace);
 }
コード例 #25
0
 public void ShouldCreateRandWithSeedExpression()
 {
     var factory = new DbExpressionFactory();
     DbMathematicalFunctionExpression mathematicalFunctionExpression = factory.Rand(factory.Constant(10));
     ValidateMathematicalFunctionExpression(mathematicalFunctionExpression, DbMathematicalFunctionExpressionType.RandSeed);
 }
コード例 #26
0
        public void ShouldCreateRoundExpression()
        {
            var factory = new DbExpressionFactory();
            DbMathematicalFunctionExpression mathematicalFunctionExpression = factory.Round(factory.Column("SomeColumn"), factory.Constant(2));

            ValidateMathematicalFunctionExpression(mathematicalFunctionExpression, DbMathematicalFunctionExpressionType.Round);
        }
コード例 #27
0
 /// <summary>
 /// Implements the operator ==.
 /// </summary>
 /// <param name="leftExpression">The left expression.</param>
 /// <param name="rightExpression">The right expression.</param>
 /// <returns>A <see cref="DbExpression"/> instance.</returns>
 public static DbExpression operator ==(DbExpression leftExpression, DbExpression rightExpression)
 {
     return(ExpressionFactory.Equal(
                leftExpression.IsNull() ? ExpressionFactory.Constant(null) : leftExpression,
                rightExpression.IsNull() ? ExpressionFactory.Constant(null) : rightExpression));
 }