Exemple #1
0
        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));
        }
Exemple #2
0
 public void InsensitiveLike(string propertyName, string value, HqlMatchMode matchMode)
 {
     Criterion = HqlRestrictions.InsensitiveLike(propertyName, value, matchMode);
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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));
        }