private static MethodInfo GetQueryableMethod(Expression expression)
{
if (expression.NodeType == ExpressionType.Call) {
var call = (MethodCallExpression)expression;
if (call.Method.IsStatic && call.Method.DeclaringType == typeof(Queryable)) {
return call.Method.GetGenericMethodDefinition();
}
}
return null;
}