Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server side projection with MongoDB C# driver 2.0

I have a collection of documents with a few small properties, and one huge property (a binary 10MB or so PDF document). I'm using the latest stable C# driver, published on 2015-04-02. Is there a way to get a list of these documents, with all the small properties, but excluding the huge binary one?

like image 902
Test_me Avatar asked Sep 28 '22 03:09

Test_me


1 Answers

You would want to use IFindFluent.Find and then use IFindFluent.Projection and Builders.Projection.Exclude to exclude this property:

var query = collection.
    Find(filter).
    Project<Document>(Builders<Document>.Projection.Exclude(doc => doc.HugeBlob));
var results = await query.ToListAsync();
like image 70
i3arnon Avatar answered Nov 09 '22 23:11

i3arnon