When we get the data from db in c#

var collection = database.GetCollection(“abc”);
when i execute the above code.
does it get the all records at that time.
or when i execute following.

List bsonPlanData = collection.AsQueryable().Where(w => w.BridgeId == “BkN”).ToList();

bsically i want to apply the where condition in db it self.
yours sincerley

Hi Rajesh,

The database.GetCollection() method creates a client-side connection object, but the server doesn’t retrieve any documents until you execute a command (such as your LINQ query).

Your query will execute on the server and return a cursor. The ToList() method will iterate the cursor and retrieve all matching results.

For more code examples, check out the C# Driver Quick Tour and the C# Quick Start blog post series.