fluent-mongo
fluent-mongo copied to clipboard
How to get raw mongo query, that is sent to MongoDB server
When running my application I have to to write to screen raw query used.
Is any method/extension method available, to get from this:
IQueryable<EventsReceiver> alldata = hr.GetCollection<EventsReceiver>"EventsReceiver").AsQueryable().Where(q => q.UserId == "123");
something similar to: db.EventsReceiver.find({ "userid" : "123" });
Regards Damir
var queryObject = ((IMongoQueryable)alldata).GetQueryObject();
this should give you back the object used to generate the query.
Thx for reply.
Could be maybe IMongoQueryable marked as "non internal" in future versions it there are no further consequences of this change?
I'm currently getting: "Cannot access internal interface IMongoQueryable here" and 'FluentMongo.Linq.IMongoQueryable' is inaccessible due to its protection level.
Using FluentMongo 1.2.0.1. / Official MOngoDB c# driver 1.2
Regards
Perhaps, or I'll find some other way of getting this out to you.
In the meantime, you can do this yourself and compile the code up.
+1 for this one. While linq abstracts all boring stuff, I would like to be able to debug some queries to see (or verify) that the correct "mongo query" is used behind the scenes.
You can always see the actual query on the server by setting the profile-level.
Maybe you guys can use log4net and enable "debug mode" via app.config. This way the client application will not be aware about all those dependencies. The only problem is that the project will depend upon log4net. I dont see this as problem.
Something along these lines would be helpful also for generating IMongoQuery for removing items.