我jqGrid
用来向用户显示一些数据。jqGrid 具有搜索功能,可以进行字符串比较,如 Equals、NotEquals、Contains、StartsWith、NotStartsWith 等。
当我使用时,StartsWith
我得到了有效的结果(看起来像这样):
Expression condition = Expression.Call(memberAccess,
typeof(string).GetMethod("StartsWith"),
Expression.Constant(value));
由于 DoesNotStartWith 不存在,我创建了它:
public static bool NotStartsWith(this string s, string value)
{
return !s.StartsWith(value);
}
这行得通,我可以创建一个字符串并像这样调用这个方法:
string myStr = "Hello World";
bool startsWith = myStr.NotStartsWith("Hello"); // false
所以现在我可以像这样创建/调用表达式:
Expression condition = Expression.Call(memberAccess,
typeof(string).GetMethod("NotStartsWith"),
Expression.Constant(value));
但我得到一个ArgumentNullException was unhandled by user code: Value cannot be null.
Parameter name: method
错误。
有谁知道为什么这不起作用或更好的方法来解决这个问题?