获取MongoDB的C#的驱动程序生成的脚本 [英] Get generated script in MongoDB C# driver

查看:383
本文介绍了获取MongoDB的C#的驱动程序生成的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MongoDB.Driver 2.0.0。 有没有什么办法可以看到生成的脚本从LINQ到MongoDB的?

I am using MongoDB.Driver 2.0.0. Is there any way to see a generated script from linq to MongoDB?

例如我的查询是这样的:

For example my query is like:

IFindFluent<ProductMapping, ProductMapping> findFluent = Collection.Find(
    x => hashValues.Contains(x.UrlHash) && x.ProductTopic == topicId);

psented在MongoDB中如何将这个(或更复杂的查询)进行重新$ P $的壳呢?

How would this (or more complex queries) be represented in the MongoDB shell?

推荐答案

请参阅i3arnon的答案使用客户端方法渲染()这是通常更容易。

EDIT

Please see i3arnon's answer for a client-side method using Render() that is usually easier.

您可以使用<一个href="http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/#enable-database-profiling-and-set-the-profiling-level"相对=nofollow>综合MongoDB的探查看到数据库已实际收到的是什么:

You can use the integrated mongodb profiler to see what the database has actually received:

db.setProfilingLevel(2); // log every request

// show the requests that mongodb has received, along with execution stats:
db.system.profile.find().pretty() 

另外,您也可以在驱动程序的源$ C ​​$ C步骤,并等待它实际创建的消息。然而,这需要从源代码编译的驱动程序,AFAIK。

Alternatively, you can step in the source code of the driver and wait for it to actually create the message. That, however, requires compiling the driver from source, AFAIK.

这篇关于获取MongoDB的C#的驱动程序生成的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆