Example #1
0
        /// <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);
        }
Example #2
0
        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)));
        }
Example #3
0
 private SqlString GetSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, string sqlTemplate)
 {
     return(criteriaQuery.RenderSQLAliases(new SqlString(sqlTemplate)).Replace("{alias}", criteriaQuery.GetSQLAlias(criteria)));
 }