public void Case_Test() { var dataSet = DataSet <SimpleModel> .Create(); var dataRow = dataSet.AddRow(); var column1 = dataSet._.Column1; _Boolean c1 = column1 == 1; _Boolean c0 = column1 == 0; var expr = Case.When(c1).Then(_Boolean.True) .When(c0).Then(_Boolean.False) .Else(_Boolean.Null); var dbExpr = (DbCaseExpression)expr.DbExpression; dbExpr.Verify(null, c1, _Boolean.True, c0, _Boolean.False, _Boolean.Null); column1[dataRow] = 1; Assert.AreEqual(true, expr[dataRow]); column1[dataRow] = 0; Assert.AreEqual(false, expr[dataRow]); column1[dataRow] = null; Assert.AreEqual(null, expr[dataRow]); }
private void TestFromBoolean(_Boolean x, Double?expectedValue) { _Double expr = (_Double)x; var dbExpr = (DbCastExpression)expr.DbExpression; dbExpr.Verify(x, typeof(bool?), typeof(Double?)); expr.VerifyEval(expectedValue); }
/// <summary> /// Constructs SQL WHERE. /// </summary> /// <param name="condition">The condition.</param> /// <returns>This query builder for fluent coding.</returns> public DbQueryBuilder Where(_Boolean condition) { condition.VerifyNotNull(nameof(condition)); VerifySourceColumn(condition, nameof(condition)); WhereExpression = And(WhereExpression, EliminateSubQuery(condition.DbExpression)); return(this); }
private void TestFromBoolean(_Boolean x, Int32?expectedValue) { _Int32 expr = (_Int32)x; var dbExpr = (DbCastExpression)expr.DbExpression; dbExpr.Verify(x, typeof(bool?), typeof(Int32?)); expr.VerifyEval(expectedValue); }
private void TestNot(_Boolean x) { var expr = !x; expr.VerifyEval(!x.Eval()); var dbExpr = (DbUnaryExpression)expr.DbExpression; dbExpr.Verify(DbUnaryExpressionKind.Not, x); }
private void TestStringColumnCast(String x, Boolean?expectedValue) { _String column1 = _String.Const(x); _Boolean expr = (_Boolean)column1; var dbExpr = (DbCastExpression)expr.DbExpression; dbExpr.Verify(column1, typeof(String), typeof(Boolean?)); expr.VerifyEval(expectedValue); }
private void TestNotEqual(bool?x, bool?y, bool?expectedValue) { _Boolean column1 = x; _Boolean column2 = y; var expr = column1 != column2; var dbExpr = (DbBinaryExpression)expr.DbExpression; dbExpr.Verify(BinaryExpressionKind.NotEqual, column1, column2); expr.VerifyEval(expectedValue); }
private void TestAnd(bool?x, bool?y, bool?expectedValue) { _Boolean left = x; _Boolean right = y; var expr = left & right; expr.VerifyEval(expectedValue); var dbExpr = (DbBinaryExpression)expr.DbExpression; dbExpr.Verify(BinaryExpressionKind.And, left, right); }
private Action <DbQueryBuilder> GetWhereQueryBuilder(_Boolean condition) { if (condition is null) { return x => { } } ; else { return(x => x.Where(condition)); } }
private DbQuery <T> Where(_Boolean condition) { var queryStatement = GetSimpleQueryStatement(GetWhereQueryBuilder(condition), out T newModel); return(DbSession.PerformCreateQuery(newModel, queryStatement)); }
/// <summary> /// Constructs SQL WHERE. /// </summary> /// <param name="condition">The condition.</param> /// <returns>This aggregate query builder for fluent coding.</returns> public new DbAggregateQueryBuilder Where(_Boolean condition) { base.Where(condition); return(this); }
private void TestImplicit(bool?x) { _Boolean column = x; column.VerifyParam(x); }
private void TestParam(bool?x) { _Boolean column = _Boolean.Param(x); column.VerifyParam(x); }
/// <summary> /// Constructs WHEN statement of CASE expression. /// </summary> /// <param name="when">The condition.</param> /// <returns>A <see cref="CaseWhen"/> struct for further expression construct.</returns> public static CaseWhen When(_Boolean when) { return(new CaseWhen(when)); }
/// <summary> /// Constructs SQL HAVING. /// </summary> /// <param name="condition">The condition.</param> /// <returns>This aggregate query builder for fluent coding.</returns> public DbAggregateQueryBuilder Having(_Boolean condition) { VerifySourceColumn(condition, nameof(condition)); HavingExpression = EliminateSubQuery(condition.DbExpression); return(this); }
/// <summary>Creates a column of parameter expression.</summary> /// <param name="x">The value of the parameter expression.</param> /// <param name="sourceColumn">The value which will be passed to <see cref="DbParamExpression.SourceColumn"/>.</param> /// <returns>The column of parameter expression.</returns> public static _Boolean Param(bool?x, _Boolean sourceColumn = null) { return(new ParamExpression <bool?>(x, sourceColumn).MakeColumn <_Boolean>()); }
private static void TestConst(bool?x) { _Boolean column = _Boolean.Const(x); column.VerifyConst(x); }