我正在学习存储过程,mysql中的游标,我偶然发现它:
delimiter //
CREATE PROCEDURE some_func()
BEGIN
DECLARE link_rewrite VARCHAR(255);
DECLARE link_rewrite_cursor CURSOR FOR SELECT link_rewrite FROM prod;
OPEN link_rewrite_cursor;
SET @count = 0;
WHILE @count < 10 DO
FETCH link_rewrite_cursor INTO link_rewrite;
SELECT link_rewrite;
set @count = @count + 1;
END WHILE;
CLOSE link_rewrite_cursor;
END//
delimiter ;
Run Code Online (Sandbox Code Playgroud)
我的问题是:为什么SELECT link_rewrite总是返回NULL(在prod表中有9000行).SELECT link_rewrite FROM prod返回很多行(9000行).
我正在使用表达式处理过滤机制,无法弄清楚如何调用任何使用Expression.Call的方法.下面的例子没有意义,但说明了我的问题:
var person = new List<String>(new[] { "Peter", "John", "Jim" });
var personQuery = person.AsQueryable();
var anyMethod = typeof(Queryable).GetMethods().FirstOrDefault(method => method.Name == "Any" && method.GetParameters().Count() == 2);
Expression<Func<String, bool>> expr = p => p == "Amy";
// person.Any(person => person == "Amy"
var call = Expression.Call(
anyMethod,
personQuery.Expression,
expr
);
Run Code Online (Sandbox Code Playgroud)
Expression.Call抛出ArgumentException:
System.ArgumentException was unhandled
HResult=-2147024809
Message=Method Boolean Any[TSource](System.Linq.IQueryable`1[TSource], System.Linq.Expressions.Expression`1[System.Func`2[TSource,System.Boolean]]) is a generic method definition.
Source=System.Core
StackTrace:
w System.Linq.Expressions.Expression.ValidateMethodInfo(MethodInfo method)
w System.Linq.Expressions.Expression.ValidateMethodAndGetParameters(Expression instance, MethodInfo method)
w System.Linq.Expressions.Expression.Call(MethodInfo method, Expression arg0, Expression …Run Code Online (Sandbox Code Playgroud)