/// <summary> /// Creates a condition expression using the provided expressions and binary operator. /// </summary> /// <param name="left">Left operand.</param> /// <param name="opr">Binary Boolean operator.</param> /// <param name="right">Right operand.</param> /// <returns>A newly created <see cref="Sql.Condition"/> object with the operands and /// operator set to the given expressions and operator.</returns> public Sql.Condition Condition(Sql.IExpression left, Sql.BooleanOperators opr = Sql.BooleanOperators.None, Sql.IExpression right = null) => new Sql.Condition(left, opr, right);
/// <summary> /// Creates a new <see cref="Sql.SortExpression"/> object from the given expression /// object with a <see cref="Sql.SortDirections.Descending"/> sort direction. /// </summary> /// <param name="expression">Expression object used in the new sort expression object.</param> /// <returns>A new sort expression object that specifies the given expression object as /// the expression to sort in <see cref="Sql.SortDirections.Descending"/> fashion.</returns> public static Sql.SortExpression Descending(this Sql.IExpression expression) => new Sql.SortExpression(expression, Sql.SortDirections.Descending);
/// <summary> /// Adds a single field-value pair to the given UPDATE statement. /// </summary> /// <typeparam name="TUpdate">The type of UPDATE statement.</typeparam> /// <param name="updateQuery">The UPDATE statement to operate on.</param> /// <param name="field">Field to update.</param> /// <param name="value">Expression that provides the field's new value.</param> /// <returns>The given UPDATE statement to enable fluent syntax.</returns> public static TUpdate Update <TUpdate>(this TUpdate updateQuery, Sql.Field field, Sql.IExpression value) where TUpdate : Sql.IUpdate => Update(updateQuery, new Sql.SetField(field, value));
/// <summary> /// Joins the given expression to another one using the Boolean OR operator, creating a /// new <see cref="Sql.Condition"/> expression. /// </summary> /// <param name="expression">The expression to the left of the OR operator.</param> /// <param name="conditionFn">A fuction delegate that, when executed, returns the /// expression to the right of the OR operator.</param> /// <returns>A new <see cref="Sql.Condition"/> object that has the original expression and /// the expression returned by the <paramref name="conditionFn"/> delegate joined by the /// OR operator.</returns> public static Sql.IExpression Or(this Sql.IExpression expression, Func <ExpressionBuilderHelper, Sql.IExpression> conditionFn) => new Sql.Condition(expression, Sql.BooleanOperators.Or, conditionFn(new ExpressionBuilderHelper()));
/// <summary> /// Defines the condition used in the SQL statement object to filter records. /// </summary> /// <typeparam name="TStatement">Type of SQL statement object.</typeparam> /// <param name="whereStatement">The SQL statement object to operate on.</param> /// <param name="condition">The expression used as the condition to the SQL statement.</param> /// <returns>The given SQL statement object to enable fluent syntax.</returns> public static TStatement Where <TStatement>(this TStatement whereStatement, Sql.IExpression condition) where TStatement : Sql.IWhere { whereStatement.Where = condition; return(whereStatement); }