/// <summary> /// Adds a field's expression to the SELECT statement with its own column name. /// If a join alias is referenced in the field expression, and the join is defined in /// field's entity class, it is automatically included in the query. /// The field is marked as a target at current index for future loading from a data reader. /// </summary> /// <param name="field">Field object</param> /// <returns>The query itself.</returns> public static SqlQuery Select(this SqlQuery query, IField field) { if (field == null) { throw new ArgumentNullException("field"); } query.EnsureJoinsInExpression(field.Expression); new SqlQuery.Column(query, field.Expression, field.ColumnAlias, field); return(query); }
/// <summary> /// Adds a field's expression to the SELECT statement with a given column name. /// If a join alias is referenced in the field expression, and the join is defined in /// field's entity class, it is automatically included in the query. /// The field is marked as a target at current index for future loading from a data reader. /// </summary> /// <param name="field">Field object</param> /// <returns>The query itself.</returns> public static SqlQuery Select(this SqlQuery query, IField field, string columnName) { if (field == null) { throw new ArgumentNullException("field"); } if (columnName == null) { throw new ArgumentNullException("columnName"); } query.EnsureJoinsInExpression(field.Expression); new SqlQuery.Column(query, field.Expression, columnName, field); return(query); }