以下代码给了我以下错误:mutationType 是一个变量,但像类型一样使用。
如何使用 Filter.OfType
和类型参数搜索具体类?
// BaseMutation is an abstract class. mutationType will contain a type of a concrete class.
public IEnumerable<BaseMutation> FindMutations(Type mutationType)
{
var filter = Builders<BaseMutation>.Filter.OfType<mutationType>();
...
}
我也试过typeof(BaseMutation).MakeGenericType(mutationType);