Пример #1
0
        /// <summary>
        /// visit a comparison expression
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Expression <Func <T, bool> > VisitComparison(QueryParser.ComparisonContext context)
        {
            var comparator = context.comparator().GetText().ToLowerInvariant();

            switch (comparator)
            {
            case "=is-null=":
            case "=nil=":
                return(QueryExpressionHelper.GetIsNullExpression <T>(_parameter, context, _namingStrategy));

            case "==":
            case "=eq=":
                return(QueryExpressionHelper.GetEqExpression <T>(_parameter, context, _namingStrategy));

            case "!=":
            case "=neq=":
                return(QueryExpressionHelper.GetNeqExpression <T>(_parameter, context, _namingStrategy));

            case "<":
            case "=lt=":
                return(QueryExpressionHelper.GetLtExpression <T>(_parameter, context, _namingStrategy));

            case "<=":
            case "=le=":
                return(QueryExpressionHelper.GetLeExpression <T>(_parameter, context, _namingStrategy));

            case ">":
            case "=gt=":
                return(QueryExpressionHelper.GetGtExpression <T>(_parameter, context, _namingStrategy));

            case ">=":
            case "=ge=":
                return(QueryExpressionHelper.GetGeExpression <T>(_parameter, context, _namingStrategy));

            case "=in=":
                return(QueryExpressionHelper.GetInExpression <T>(_parameter, context, _namingStrategy));

            case "=out=":
            case "=nin=":
                return(QueryExpressionHelper.GetOutExpression <T>(_parameter, context, _namingStrategy));

            default:
                throw new QueryComparisonUnknownComparatorException(context);
            }
        }
 public QueryComparisonUnknownComparatorException(QueryParser.ComparisonContext origin,
                                                  Exception innerException = null) : base(origin,
                                                                                          string.Format("Unknown comparator : {0}", origin.comparator().GetText()), innerException)
 {
 }