public static BinaryExpression Like(string propertyName, string value, HqlMatchMode matchMode) { switch (matchMode) { case HqlMatchMode.Start: value = "'" + FormatValue(value, false) + "%'"; break; case HqlMatchMode.Exact: value = "'" + FormatValue(value, false) + "'"; break; case HqlMatchMode.Anywhere: value = "'%" + FormatValue(value, false) + "%'"; break; case HqlMatchMode.End: value = "'%" + FormatValue(value, false) + "'"; break; } return(new BinaryExpression("like", propertyName, value)); }
public void InsensitiveLike(string propertyName, string value, HqlMatchMode matchMode) { Criterion = HqlRestrictions.InsensitiveLike(propertyName, value, matchMode); }
public static void InsensitiveLikeSpecificAlias(this IHqlExpressionFactory hqlExpressionFactory, string alias, string propertyName, string value, HqlMatchMode matchMode) { var aux = (hqlExpressionFactory as DefaultHqlExpressionFactory); aux.InsensitiveLike(propertyName, value, matchMode); var criterion = GetCriterion(alias, propertyName, value, matchMode); var property = typeof(DefaultHqlExpressionFactory).GetProperty("Criterion"); property.SetValue(aux, criterion); }
public static IHqlCriterion InsensitiveLike(string propertyName, string value, HqlMatchMode matchMode) { var expression = Like(propertyName, value, matchMode); expression.ProcessPropertyName = x => String.Concat("lower(", x, ")"); return(expression); }
private static IHqlCriterion GetCriterion(string alias, string propertyName, string value, HqlMatchMode matchMode) { Func <string, string> processAlias = s => alias + s.Substring(s.IndexOf(".")); switch (matchMode) { case HqlMatchMode.Start: value = "'" + HqlRestrictions.FormatValue(value, false) + "%'"; break; case HqlMatchMode.Exact: value = "'" + HqlRestrictions.FormatValue(value, false) + "'"; break; case HqlMatchMode.Anywhere: value = "'%" + HqlRestrictions.FormatValue(value, false) + "%'"; break; case HqlMatchMode.End: value = "'%" + HqlRestrictions.FormatValue(value, false) + "'"; break; } return(new BinaryExpression("like", propertyName, value, processAlias)); }