本文介绍了MongoDB-无法使用.explain()获取C#代码中的查询信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Mongo 2.2 .如何使用C#访问查询信息?
I'm using Mongo 2.2. How can I access the query info using C#?
目前有以下信息可获取我的数据:
Currently have the following to get my data:
var records = _collection.Find(filters).ToList<Vehicle>();
我试图添加一个.explain(),类似于在查询结束时在Robomongo中可以执行的操作:
I was trying to add a .explain() similarily to what I can do in Robomongo at the end of my query:
var records = _collection.Find(filters).explain();
但是,它不存在,我相信是因为它不是游标.有人知道我如何在C#中获取此查询数据吗?
However, it does not exist, I believe because its not a cursor. Does anyone know how I can get this query data in C#?
推荐答案
MongoCursor类的.Explain()方法是MongoCollection类的FindAs()方法产生的.我从此链接找到了答案.
There is .Explain() method of MongoCursor class resulting from FindAs() method of MongoCollection class. I found an answer from this link.
var qLinq = Query<T>.Where(x => x.name=="jim");
var exp = Collection.FindAs<T>(qLinq).Explain()
这篇关于MongoDB-无法使用.explain()获取C#代码中的查询信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!