Message from discussion
C# Linq Provider - Mongo Driver - How to view / tell the Mongo query that is about to be sent to the server?
Received: by 10.58.133.75 with SMTP id pa11mr1204283veb.20.1350067938478;
Fri, 12 Oct 2012 11:52:18 -0700 (PDT)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.220.141.4 with SMTP id k4ls2474189vcu.8.gmail; Fri, 12 Oct
2012 11:52:09 -0700 (PDT)
Received: by 10.58.19.99 with SMTP id d3mr1136711vee.32.1350067929437;
Fri, 12 Oct 2012 11:52:09 -0700 (PDT)
Received: by 10.58.19.99 with SMTP id d3mr1136710vee.32.1350067929422;
Fri, 12 Oct 2012 11:52:09 -0700 (PDT)
Return-Path: <rob...@10gen.com>
Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50])
by gmr-mx.google.com with ESMTPS id bn19si573062vdb.0.2012.10.12.11.52.09
(version=TLSv1/SSLv3 cipher=OTHER);
Fri, 12 Oct 2012 11:52:09 -0700 (PDT)
Received-SPF: pass (google.com: domain of rob...@10gen.com designates 209.85.212.50 as permitted sender) client-ip=209.85.212.50;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of rob...@10gen.com designates 209.85.212.50 as permitted sender) smtp.mail=rob...@10gen.com
Received: by mail-vb0-f50.google.com with SMTP id fa15so4005437vbb.37
for <mongodb-user@googlegroups.com>; Fri, 12 Oct 2012 11:52:09 -0700 (PDT)
d=google.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type:x-gm-message-state;
bh=h/zF0pkrg3u4rdums8BdvaAt/9qv+TjNgVh+Jc8dkm0=;
b=I7eOKVdJdW7vsKbJJud4WACxPltwJqzWrkmVAyFpDozfGkdIAQ7DXrEWjMiXGNp5oU
PHyE9GdiFYSA/+eIICRrLnxXjd6oPuXsyxo41/a2PPmFkPy89qN5EPZ1uQWlMZ/oYm1a
PFLR3fqlxxol3xbas/4lS79gO/3QM+wMi53rLO3T+9LHqy1oocx5J+zsX4TMqOc+Jl2s
mruDpngPPC2FllJTCssIRpI6L1VNoVaNCOeCo12LgNN8D8UnhWkb47qSNkNkPq8eF5jU
R0K2sZk1DWgKLAvgKBDdvD3MY9ZNYQRxF7jUEtvAS5zKP0KLVQNeL1XrYPt7IMCH+z0R
j9dg==
MIME-Version: 1.0
Received: by 10.52.97.165 with SMTP id eb5mr2436053vdb.75.1350067929240; Fri,
12 Oct 2012 11:52:09 -0700 (PDT)
Received: by 10.58.135.6 with HTTP; Fri, 12 Oct 2012 11:52:09 -0700 (PDT)
In-Reply-To: <09bf7500-7d09-47ac-8477-ada8d5b51948@googlegroups.com>
References: <09bf7500-7d09-47ac-8477-ada8d5b51948@googlegroups.com>
Date: Fri, 12 Oct 2012 14:52:09 -0400
Message-ID: <CAJCJWG2kdC6D--yNBtfjD+rn8H+vBXa_HYdj9gk4_mvHKi=...@mail.gmail.com>
Subject: Re: [mongodb-user] C# Linq Provider - Mongo Driver - How to view /
tell the Mongo query that is about to be sent to the server?
From: Robert Stam <rob...@10gen.com>
To: mongodb-user@googlegroups.com
Content-Type: multipart/alternative; boundary=20cf307d04085853a804cbe12f76
X-Gm-Message-State: ALoCoQmnfNHRCwx/qDJKHvPqXAbXqSqAgzg1Bybi9Myd4Mm8LR9CWE5zVj2rGLfvoZFBY0ZicgaZ
--20cf307d04085853a804cbe12f76
Content-Type: text/plain; charset=ISO-8859-1
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 <jonathan.g...@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 mongodb-user@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
>
--20cf307d04085853a804cbe12f76
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
There is. You can do this:<div><br></div><div><div><font face=3D"courier ne=
w, monospace">=A0 =A0 var query =3D</font></div><div><font face=3D"courier =
new, monospace">=A0 =A0 =A0 =A0 from x in collection.AsQueryable<C>()=
</font></div><div>
<font face=3D"courier new, monospace">=A0 =A0 =A0 =A0 where x.Id =3D=3D 1</=
font></div><div><font face=3D"courier new, monospace">=A0 =A0 =A0 =A0 selec=
t x;</font></div><div><font face=3D"courier new, monospace"><br></font></di=
v><div><font face=3D"courier new, monospace">=A0 =A0 var json =3D ((MongoQu=
eryable<C>)query).GetMongoQuery().ToJson();</font></div>
<div><br></div><div><br></div><div>The json variable is now a string that r=
epresents the native MongoDB query.</div><br><div class=3D"gmail_quote">On =
Fri, Oct 12, 2012 at 2:41 PM, Jonathan Gill <span dir=3D"ltr"><<a href=
=3D"mailto:jonathan.g...@gmail.com" target=3D"_blank">jonathan.g...@gmail.c=
om</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">We're having an issue were we need to se=
e 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.<br>
<br>Is there a property or way to view this in C# from the IQueryable that =
is being built up?<span class=3D"HOEnZb"><font color=3D"#888888"><br>
<p></p>
-- <br>
You received this message because you are subscribed to the Google<br>
Groups "mongodb-user" group.<br>
To post to this group, send email to <a href=3D"mailto:mongodb-user@googleg=
roups.com" target=3D"_blank">mongodb-user@googlegroups.com</a><br>
To unsubscribe from this group, send email to<br>
<a href=3D"mailto:mongodb-user%2Bunsubscribe@googlegroups.com" target=3D"_b=
lank">mongodb-user+unsubscribe@googlegroups.com</a><br>
See also the IRC channel -- <a href=3D"http://freenode.net#mongodb" target=
=3D"_blank">freenode.net#mongodb</a><br>
</font></span></blockquote></div><br></div>
--20cf307d04085853a804cbe12f76--