예제 #1
0
        /// <summary>
        /// Joins two tables using on an array join condition
        /// </summary>
        /// <param name="type">The type of join to be created.</param>
        /// <param name="leftTable">The left table</param>
        /// <param name="rightTable">The right table</param>
        /// <param name="conditions">An array of equality condition to be applied on the join</param>
        /// <remarks>
        /// A logical AND will be applied on the conditions.
        /// Schematically, the resulting SQL will be ... x join y on (cond1 and cond2 and cond3 and ... and condN) ...
        /// </remarks>
        public void Join(JoinType type, FromTerm leftTable, FromTerm rightTable, JoinCondition[] conditions)
        {
            WhereClause clause = new WhereClause(WhereRel.And);

            foreach (JoinCondition cond in conditions)
            {
                clause.Terms.Add(WhereTerm.CreateCompare(OmExpression.Field(cond.LeftField, leftTable), OmExpression.Field(cond.RightField, rightTable), CompCond.Equal));
            }

            Join(type, leftTable, rightTable, clause);
        }
예제 #2
0
 /// <summary>
 /// Creates a SelectColumn with a column name, table, column alias and optional aggregation function
 /// </summary>
 /// <param name="columnName">Name of a column</param>
 /// <param name="table">The table this field belongs to</param>
 /// <param name="columnAlias">Alias of the column</param>
 /// <param name="function">Aggregation function to be applied to the column. Use SqlAggregationFunction.None to specify that no function should be applied.</param>
 public SelectColumn(string columnName, FromTerm table, string columnAlias, AggFunc function)
 {
     if (function == AggFunc.None)
     {
         Expression = OmExpression.Field(columnName, table);
     }
     else
     {
         Expression = OmExpression.Function(function, OmExpression.Field(columnName, table));
     }
     this.ColumnAlias = columnAlias;
 }