/// <summary> /// Substitute the SQL aliases in <see cref="SqlString"/> template. /// </summary> public SqlString RenderSQLAliases(SqlString sqlTemplate) { var result = criteriaSQLAliasMap .Where(p => !string.IsNullOrEmpty(p.Key.Alias)) .Aggregate(sqlTemplate, (current, p) => current.Replace("{" + p.Key.Alias + "}", p.Value)); if (outerQueryTranslator != null) { return(outerQueryTranslator.RenderSQLAliases(result)); } return(result); }
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery) { var parameters = _sql.GetParameters().ToList(); var paramPos = 0; for (int i = 0; i < _typedValues.Length; i++) { var controlledParameters = criteriaQuery.NewQueryParameter(_typedValues[i]); foreach (Parameter parameter in controlledParameters) { parameters[paramPos++].BackTrack = parameter.BackTrack; } } return(criteriaQuery.RenderSQLAliases(_sql).Replace("{alias}", criteriaQuery.GetSQLAlias(criteria))); }
private SqlString GetSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, string sqlTemplate) { return(criteriaQuery.RenderSQLAliases(new SqlString(sqlTemplate)).Replace("{alias}", criteriaQuery.GetSQLAlias(criteria))); }