[CSHARP-2356] prefix-lile fields like Name and NameOfPet ruin projection Created: 14/Aug/18  Updated: 28/Oct/23  Resolved: 09/Nov/22

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

Type: Bug Priority: Major - P3
Reporter: Igor Betin Assignee: James Kovacs
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change

 Description   

In case projection looks like
(item => new Result { Connection = item.Connection, ConnectionType = item.ConnectionType} )
the method in question returns only one field - Connection
It results in FindProjectionTranslator.VisitField not finding ConnectionType in fields list and it mistakenly sets _fullDocument = true, wich results in using ProjectingDeserializer that deserializes whole (very large) document and slows our system like x10 times.

The fix is proposed here (in April)
https://github.com/mongodb/mongo-csharp-driver/pull/323



 Comments   
Comment by James Kovacs [ 09/Nov/22 ]

This issue has been fixed in the new LINQ provider (known as LINQ3), which was introduced in the 2.14 release.

Configure your MongoClientSettings to use LinqProvider.V3 if you want to use this functionality.

To configure a client to use the LINQ3 provider use code like the following

var connectionString = "mongodb://localhost";
var clientSettings = MongoClientSettings.FromConnectionString(connectionString);
clientSettings.LinqProvider = LinqProvider.V3;
var client = new MongoClient(clientSettings);

Comment by Ian Whalen (Inactive) [ 19/Nov/18 ]

Hi Igor, sorry for the delay and thanks for sending the bug report + pull request. Before we can investigate merging this, could you please put up an additional patch with tests?

Comment by Igor Betin [ 31/Aug/18 ]

Was this one noticed?

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