/// <summary> /// AND's the specified <paramref name="andCondition"/> to the QueryBuilder. /// </summary> /// <param name='andCondition'> /// The condition to be ANDed. /// </param> public QueryBuilder Where(SqlFragment andCondition) { if (whereCondition == null) { whereCondition = new WhereCondition(andCondition); } else { whereCondition.And(andCondition); } return(this); }
/// <summary> /// Joins the table of name <paramref name="joined_table_name"/>, represented by type <typeparamref name="JT" /> to the root entity, the join condition /// being expressed in <paramref name="joinCondition"/>. /// </summary> /// <param name="joined_table_name">The real name of the table to be joined, as it is in the database.</param> /// <param name="joinType">The type of join (inner, outer etc.)</param> /// <typeparam name="JT">The type that represents the newly joined table.</typeparam> public RootQueryBuilder <T> Join <JT>(string joined_table_name, Expression <Func <T, JT, bool> > joinCondition, JoinType joinType) { if (QueriedTables.ContainsKey(joined_table_name)) { throw new InvalidOperationException("This table has already been queried/joined. Please use a method that allows you to join to the same table more than once."); } var conditionBuilder = new WhereConditionGeneratorTreeVisitor(); conditionBuilder.AddType(RootTable, RootEntityType); conditionBuilder.AddType(joined_table_name, typeof(JT)); conditionBuilder.Visit(joinCondition); WhereCondition condFragment = conditionBuilder.Fragment; Qb.Join(joined_table_name, condFragment, joinType); return(this); }
public WhereConditionGeneratorTreeVisitor() : base() { Fragment = new WhereCondition(); TableEntities = new Dictionary <Type, string>(2); }