public void ShouldCreateAddExpression() { var factory = new DbExpressionFactory(); DbBinaryExpression binaryExpression; binaryExpression = factory.Add(factory.Constant(1), factory.Constant(2)); ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Add); }
public void ShouldCreateAssignmentExpression() { var factory = new DbExpressionFactory(); DbBinaryExpression binaryExpression; binaryExpression = factory.Assign(factory.Constant(1), factory.Constant(2)); ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Assignment); }
public void ShouldCreateLessThanOrEqualExpression() { var factory = new DbExpressionFactory(); DbBinaryExpression binaryExpression; binaryExpression = factory.LessThanOrEqual(factory.Constant(1), factory.Constant(2)); ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.LessThanOrEqual); }
public void ShouldCreateOrExpression() { var factory = new DbExpressionFactory(); DbBinaryExpression binaryExpression; binaryExpression = factory.Or(factory.Constant(1), factory.Constant(2)); ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Or); }
public void ShouldCreateSubstractExpression() { var factory = new DbExpressionFactory(); DbBinaryExpression binaryExpression; binaryExpression = factory.Subtract(factory.Constant(1), factory.Constant(2)); ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.Subtract); }
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); }
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); }
public void ShouldCreateAddMinutesExpression() { var factory = new DbExpressionFactory(); DbDateTimeFunctionExpression dateTimeFunctionExpression; dateTimeFunctionExpression = factory.AddMinutes(factory.Column("SomeDateTimeColumn"), factory.Constant(2)); ValidateDateTimeFunctionExpression(dateTimeFunctionExpression, DbDateTimeFunctionExpressionType.AddMinutes); }
public void ShouldCreateContantExpression() { var factory = new DbExpressionFactory(); var expression = factory.Constant("SomeValue"); Assert.IsNotNull(expression.Value); Assert.IsTrue(expression.ExpressionType == DbExpressionType.Constant); }
/// <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))); }
public void ShouldCreateAddMillisecondsExpression() { var factory = new DbExpressionFactory(); DbDateTimeFunctionExpression dateTimeFunctionExpression; dateTimeFunctionExpression = factory.AddMilliseconds(factory.Column("SomeDateTimeColumn"), factory.Constant(2)); ValidateDateTimeFunctionExpression(dateTimeFunctionExpression, DbDateTimeFunctionExpressionType.AddMilliseconds); }
public void ShouldCreateSubStringExpression() { var factory = new DbExpressionFactory(); var stringFunctionExpression = factory.SubString(factory.Column("SomeStringColumn"), factory.Constant(1), factory.Constant(2)); ValidateStringFunctionExpression(stringFunctionExpression, DbStringFunctionExpressionType.SubString); }
public void ShouldCreateGreaterThanExpression() { var factory = new DbExpressionFactory(); DbBinaryExpression binaryExpression; binaryExpression = factory.GreaterThan(factory.Constant(1), factory.Constant(2)); ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.GreaterThan); }
public void ShouldCreateReplaceExpression() { var factory = new DbExpressionFactory(); var stringFunctionExpression = factory.Replace(factory.Column("SomeStringColumn"), factory.Constant("OldValue"), factory.Constant("NewValue")); ValidateStringFunctionExpression(stringFunctionExpression, DbStringFunctionExpressionType.Replace); }
public void ShouldCreateNotEqualExpression() { var factory = new DbExpressionFactory(); DbBinaryExpression binaryExpression; binaryExpression = factory.NotEqual(factory.Constant(1), factory.Constant(2)); ValidateBinaryExpression(binaryExpression, DbBinaryExpressionType.NotEqual); }
/// <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); }
public void ShouldCreateRandWithSeedExpression() { var factory = new DbExpressionFactory(); DbMathematicalFunctionExpression mathematicalFunctionExpression = factory.Rand(factory.Constant(10)); ValidateMathematicalFunctionExpression(mathematicalFunctionExpression, DbMathematicalFunctionExpressionType.RandSeed); }
public void ShouldCreateRoundExpression() { var factory = new DbExpressionFactory(); DbMathematicalFunctionExpression mathematicalFunctionExpression = factory.Round(factory.Column("SomeColumn"), factory.Constant(2)); ValidateMathematicalFunctionExpression(mathematicalFunctionExpression, DbMathematicalFunctionExpressionType.Round); }
/// <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)); }