コード例 #1
0
        private void HandleParamStringFunctions(MethodCallExpression node)
        {
            var name = GetColumnName(node.Object as MemberExpression);

            object firstArg = null;

            if (node.Arguments.HasItems())
            {
                firstArg = node.Arguments[0].GetValue();
            }
            string value = "";

            switch (node.Method.Name)
            {
            case "StartsWith":
                value = $"{name} like @{Parameters.CurrentIndex}";
                Parameters.AddValues(firstArg + "%");
                break;

            case "EndsWith":
                value = $"{name} like @{Parameters.CurrentIndex}";
                Parameters.AddValues("%" + firstArg);
                break;

            case "Contains":
                value = $"{name} like @{Parameters.CurrentIndex}";
                Parameters.AddValues("%" + firstArg + "%");
                break;

            case "ToUpper":
            case "ToUpperInvariant":
                value = _provider.ToUpper(name);
                break;

            case "ToLower":
            case "ToLowerInvariant":
                value = _provider.ToLower(name);
                break;

            case "Substring":
                value = _provider.Substring(name, (int)firstArg, (int)node.Arguments[1].GetValue());
                break;
            }

            _sb.Append(value);
        }
コード例 #2
0
 public void to_lower()
 {
     Get(d => d.Title.ToLower());
     A.CallTo(() => _provider.ToLower("Title")).MustHaveHappened();
 }