private object[] GetColumnsOrAliases(ICriteria criteria, ICriteriaQuery criteriaQuery) { var propName = propertyName ?? (projection as IPropertyProjection)?.PropertyName; return(propName != null ? criteriaQuery.GetColumnAliasesUsingProjection(criteria, propName) : (object[])CriterionUtil.GetColumnNamesUsingProjection(projection, criteriaQuery, criteria)); }
public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters) { SqlString[] columns = CriterionUtil.GetColumnNamesUsingProjection(projection, criteriaQuery, criteria, enabledFilters); if (columns.Length != 1) { throw new HibernateException("Like may only be used with single-column properties / projections."); } SqlStringBuilder lhs = new SqlStringBuilder(6); if (ignoreCase) { Dialect.Dialect dialect = criteriaQuery.Factory.Dialect; lhs.Add(dialect.LowercaseFunction) .Add(StringHelper.OpenParen) .Add(columns[0]) .Add(StringHelper.ClosedParen); } else { lhs.Add(columns[0]); } criteriaQuery.AddUsedTypedValues(GetTypedValues(criteria, criteriaQuery)); if (ignoreCase) { Dialect.Dialect dialect = criteriaQuery.Factory.Dialect; lhs.Add(" like ") .Add(dialect.LowercaseFunction) .Add(StringHelper.OpenParen) .AddParameter() .Add(StringHelper.ClosedParen); } else { lhs.Add(" like ").AddParameter(); } if (escapeChar.HasValue) { lhs.Add(" escape '" + escapeChar + "'"); } return(lhs.ToSqlString()); }