Re: [mongodb-user] C# Linq Provider - Mongo Driver - How to view / tell the Mongo query that is about to be sent to the server?

198 views
Skip to first unread message

Robert Stam

unread,
Oct 12, 2012, 2:52:09 PM10/12/12
to mongod...@googlegroups.com
There is. You can do this:

    var query =
        from x in collection.AsQueryable<C>()
        where x.Id == 1
        select x;

    var json = ((MongoQueryable<C>)query).GetMongoQuery().ToJson();


The json variable is now a string that represents the native MongoDB query.

On Fri, Oct 12, 2012 at 2:41 PM, Jonathan Gill <jonath...@gmail.com> wrote:
We're having an issue were we need to see the Mongo query that is being sent to Mongo from the Mongo C# driver's LINQ provider for a "complex" query with ANDs and ORs.

Is there a property or way to view this in C# from the IQueryable that is being built up?

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Reply all
Reply to author
Forward
0 new messages