我有以下扩展方法定义:
public static IQueryable<T> FindAllOfType<T, TCollection>(this MongoCollection<TCollection> collection)
{
return collection.FindAs<T>(Query.EQ("_t", typeof(T).Name)).AsQueryable();
}
我正在尝试使用以下代码来检索MethodInfo
,因此我可以使用仅在运行时已知的类型(不是真正相关)来调用泛型方法:
MethodInfo method = typeof(MongoCollection<TCollection>).GetMethod("FindAllOfType", BindingFlags.Public | BindingFlags.Static);
但它返回null。我也试过没有像这样的通用:
MethodInfo method = typeof(MongoCollection).GetMethod("FindAllOfType", BindingFlags.Public | BindingFlags.Static);
但得到相同的结果。
有人能发现我在这里做错了吗?