Esempio n. 1
0
        public override string Parse(IDictionary <string, object> parameterDictionary, Expression functionExpressionNode)
        {
            var expressionBuilder = new StringBuilder();
            var exp           = (MethodCallExpression)functionExpressionNode;
            var expParser     = SqlDbQueryExpressionFactory.GetNodeParser(exp, ModelStrategy);
            var argExp        = SqlDbQueryExpressionFactory.GetNodeParser(exp.Arguments.First(), ModelStrategy);
            var callSourceExp = SqlDbQueryExpressionFactory.GetNodeParser(exp.Object, ModelStrategy);
            var argument      = argExp.Parse(parameterDictionary, exp.Arguments.First());

            expressionBuilder.Append("CHARINDEX(");
            expressionBuilder.Append(argExp.Parse(parameterDictionary, exp.Arguments.First()));
            expressionBuilder.Append(", ");
            expressionBuilder.Append(callSourceExp.Parse(parameterDictionary, exp.Object));
            expressionBuilder.Append(")");

            return(expressionBuilder.ToString());
        }
        public override string Parse(IDictionary <string, object> parameterDictionary, Expression functionExpressionNode)
        {
            var expressionBuilder = new StringBuilder();
            var exp = functionExpressionNode as MethodCallExpression;

            if (exp.Object == null)
            {
                throw new NotSupportedException();
            }
            else
            {
                var expParser     = SqlDbQueryExpressionFactory.GetNodeParser(exp, ModelStrategy);
                var argExp        = SqlDbQueryExpressionFactory.GetNodeParser(exp.Arguments.First(), ModelStrategy);
                var callSourceExp = SqlDbQueryExpressionFactory.GetNodeParser(exp.Object, ModelStrategy);
                var argument      = argExp.Parse(parameterDictionary, exp.Arguments.First());

                expressionBuilder.Append(callSourceExp.Parse(parameterDictionary, exp.Object));
                expressionBuilder.Append(" LIKE '%");
                expressionBuilder.Append(argument.Substring(1));
                expressionBuilder.Append(" ");
            }

            return(expressionBuilder.ToString());
        }