/// <summary> /// Joins two tables using on an arbitrary 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">Specifies how the join should be performed</param> /// <remarks> /// Use this overload to create complex join conditions. /// Note that not all <see cref="WhereClause"/> operators and expressions are supported in joins. /// </remarks> /// <example> /// WhereClause condition = new WhereClause(WhereClauseRelationship.Or); /// condition.Terms.Add(WhereTerm.CreateCompare(SqlExpression.Field("productId", tOrders), SqlExpression.Field("productId", tProducts), CompareOperator.Equal)); /// condition.Terms.Add(WhereTerm.CreateCompare(SqlExpression.Field("productName", tOrders), SqlExpression.Field("productName", tProducts), CompareOperator.Equal)); /// query.FromClause.Join(JoinType.Left, tOrders, tProducts, condition); /// </example> public void Join(JoinType type, FromTerm leftTable, FromTerm rightTable, WhereClause conditions) { if (conditions.IsEmpty && type != JoinType.Cross) { throw new InvalidQueryException("A join must have at least one condition."); } joins.Add(new Join(leftTable, rightTable, conditions, type)); }