[CSHARP-1840] How to use “find” Shell Created: 29/Nov/16  Updated: 05/Apr/19  Resolved: 30/Nov/16

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Hu Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I write some code for run shell

var args = new EvalArgs

{ Args = Params.ToArray(), Code = js }

;
var result = mongoDb.Eval(args);
txtResult.Text = result.ToJson(MongoHelper.JsonWriterSettings);

When I run shell db.GroupTest.find({}); via C#.
the result looks like

{
"_mongo" :

{ "slaveOk" : false, "host" : "EMBEDDED" }

,
"_db" : {
"_mongo" :

{ "slaveOk" : false, "host" : "EMBEDDED" }

,
"_name" : "MongoBooster"
},
"_collection" : {
"_mongo" :

{ "slaveOk" : false, "host" : "EMBEDDED" }

,
"_db" : {
"_mongo" :

{ "slaveOk" : false, "host" : "EMBEDDED" }

,
"_name" : "MongoBooster"
},
"_shortName" : "GroupTest",
"_fullName" : "MongoBooster.GroupTest"
},
"_ns" : "MongoBooster.GroupTest",
"_query" : { },
"_fields" : null,
"_limit" : 0.0,
"_skip" : 0.0,
"_batchSize" : 0.0,
"_options" : 0.0,
"_cursor" : null,
"_numReturned" : 0.0,
"_special" : false
}

what I really want is the dataset records. How can I do it?Thank you.
The code below will return what I want,but , I want to get the result without use toArray() method,just like mongo.exe
var c = db.GroupTest.find({});
return c.toArray();



 Comments   
Comment by Robert Stam [ 30/Nov/16 ]

When using a driver you should always use the API provided by that driver, not the API provided by the shell.

Also, use of eval is deprecated and it is likely to be removed entirely from the server at some point.

Generated at Wed Feb 07 21:40:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.