Examine query generated from MongoDB projection by C# driver
NickName:Jeffrey Zhao Ask DateTime:2018-05-31T04:23:47

Examine query generated from MongoDB projection by C# driver

I'm querying data with C# driver for mongodb using projection. The code is like:

var filter = Builders<User>.Filter.Eq("_id", userId);
var projection = Builders<User>.Projection.Expression(u => Tuple.Create(u.UserId, u.UserName));
var cursor = await collection.Find(filter).Project(projection).ToCursorAsync();

How do I check the query generated by the C# code?

Copyright Notice:Content Author:「Jeffrey Zhao」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50612838/examine-query-generated-from-mongodb-projection-by-c-sharp-driver

More about “Examine query generated from MongoDB projection by C# driver” related questions

Examine query generated from MongoDB projection by C# driver

I'm querying data with C# driver for mongodb using projection. The code is like: var filter = Builders&lt;User&gt;.Filter.Eq("_id", userId); var projection = Builders&lt;User&gt;.Projection.Expres...

Show Detail

$ Projection query from mongodb to mongoose

I want want to replicate this query in mongoose. db.collection.find( { &lt;array&gt;: &lt;value&gt; ... }, { "&lt;array&gt;.$": 1 } ) Doing the same query in mongoose does not work. Also I ca...

Show Detail

MongoDB Documentation (Projection vs. Query)

Was checking the MongoDB docs yesterday and noticed a lot of their operators have two entries, one under projection and one under query. What's the difference between the two? They seem to pretty...

Show Detail

Query projection with MongoDB 10gen driver

Recently i was playing with mongodb official driver. The problem that i've encountered was how to make query projection. Example if i have a persisted object class A{ id PropA PropB List&lt;

Show Detail

MongoDB C# - .First() predicate not working in a projection

I have a document like this: { "parent1" : "foo", "parent2" : "bar", "parent3" : "ignore", "parent4" : "ignore", "Items": [{

Show Detail

Calculate field in a projection mongodb c#

I have the following query in mongoDB pdb.getCollection('articulo').aggregate( { $match: { $text: { $search: "monitor" } } , }, { $project: { _id: 1, ..

Show Detail

MongoDb $projection query on C#

I need help on how to build a MongoDB query from the C# Driver. What I'm trying to make is a datediff in milliseconds and then filter those results where the datediff in milliseconds is greater or ...

Show Detail

How to query mongodb with a regex in the projection?

Does anyone know if there is a way to query MongoDB and have only certain fields returned by using a regex as part of the projection? For example: Given a collection having arbitrary field names,...

Show Detail

CosmosDB MongoDB adapter projection not working

I'm making request to CosmosDB database via MongoDB adapter from HapiJS server. My request looks like so: dbo .collection("storage") .find(query, function(

Show Detail

MongoDB - PHP - Unsupported projection option

The following command works from the mongo command line: db.users.aggregate([ {'$match': 'eventDate': {$gte: ISODate("2015-01-01T00:00:00.0Z"), $lte: ISODate("2017-01-01T00:...

Show Detail