/// <summary> /// Joins the given table object with another table object using a right outer join. /// </summary> /// <param name="left">Left table in the JOIN operation.</param> /// <param name="right">Right table in the JOIN operation.</param> /// <param name="conditionFn">Condition generator function used to obtain the join condition.</param> /// <param name="alias">Optional alias for the result.</param> /// <returns>A new <see cref="Sql.JoinedTable"/> object.</returns> public static Sql.JoinedTable RightJoin(this Sql.ITable left, Sql.ITable right, Func <Sql.ITable, Sql.ITable, Sql.Condition> conditionFn, string alias = null) => Join(left, right, Sql.TableJoins.Right, conditionFn, alias);
/// <summary> /// Joins the given table object with another table object using the specified join type and /// join condition generator function. /// </summary> /// <param name="left">Left table in the JOIN operation.</param> /// <param name="right">Left table in the JOIN operation.</param> /// <param name="joinType">Type of join to perform.</param> /// <param name="conditionFn">Condition generator function used to obtain the join condition.</param> /// <param name="alias">Optional alias for the result.</param> /// <returns>A new <see cref="Sql.JoinedTable"/> object.</returns> public static Sql.JoinedTable Join(this Sql.ITable left, Sql.ITable right, Sql.TableJoins joinType, Func <Sql.ITable, Sql.ITable, Sql.Condition> conditionFn, string alias = null) => new Sql.JoinedTable(left, right, joinType, conditionFn(left, right), alias);
/// <summary> /// Creates a new field object that is associated to the given table object. /// </summary> /// <param name="table">The table used as owner table for the new field object.</param> /// <param name="name">The field's name.</param> /// <param name="alias">The field's alias.</param> /// <returns>The newly created field object.</returns> public static Sql.Field Field(this Sql.ITable table, string name, string alias = null, Action <Sql.Field> fieldCfgFn = null) { Sql.Field field = new Sql.Field(name, table, alias); fieldCfgFn?.Invoke(field); return(field); }
/// <summary> /// Creates a new field object that represents all fields of the given table object. /// </summary> /// <param name="table">The table used as owner table for the new all fields object.</param> /// <returns>The newly created all fields object.</returns> public static Sql.Field AllFields(this Sql.ITable table) => new Sql.Field(Sql.Field.AllFieldsName, table);
/// <summary> /// Defines the fields for an INSERT statement. /// </summary> /// <typeparam name="TInsertQuery">Type of INSERT statement.</typeparam> /// <param name="insertQuery">The insert statement object to operate on.</param> /// <param name="table">The destination table for the new record.</param> /// <param name="fieldNames">The list of field names to include in the INSERT operation.</param> /// <returns>The given insert query statement to enable fluent syntax.</returns> public static TInsertQuery Insert <TInsertQuery>(this TInsertQuery insertQuery, Sql.ITable table, params string[] fieldNames) where TInsertQuery : Sql.SimpleInsertQuery { List <Sql.Field> fields = new List <Sql.Field>(); foreach (string fieldName in fieldNames) { fields.Add(new Sql.Field(fieldName, table)); } return(Insert(insertQuery, fields)); }