5

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?

i3arnon
  • 113,022
  • 33
  • 324
  • 344
Test_me
  • 393
  • 4
  • 13

1 Answers1

4

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();
i3arnon
  • 113,022
  • 33
  • 324
  • 344
  • I read somewhere that projection is client side and doesnt affect the load that returns from thr mongoDb..can you confirm this happens on mongo's side? – Ori Refael Oct 07 '15 at 15:04
  • 1
    @OriRefael yes. You can also see the eventual server-side query with `query.ToString`. – i3arnon Oct 07 '15 at 15:22
  • @i3arnon - Can you please answer the following question - http://stackoverflow.com/questions/37801269/step-by-step-single-where-clause-query-in-a-embedded-document-of-mongodb-collect/37802879?noredirect=1#comment63070962_37802879 – B.Balamanigandan Jun 14 '16 at 04:35