[CSHARP-1958] LINQ Any() invokes document deserialization Created: 07/Apr/17 Updated: 01/Nov/23 Resolved: 01/Nov/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | 2.4.3 |
| Fix Version/s: | 2.19.0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Viktor Svyatokha | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Documentation Changes: | Not Needed |
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
|
The desired result of using Any() Linq method is to get boolean value. In case when document can't be deserialized now I get exception instead of getting proper result.
the query is translated to fetching at least one document. |
| Comments |
| Comment by Robert Stam [ 01/Nov/23 ] |
|
This issue does not exist in LINQ3. |
| Comment by Viktor Svyatokha [ 08/May/17 ] |
|
Proposed PR: https://github.com/mongodb/mongo-csharp-driver/pull/278 |
| Comment by Robert Stam [ 10/Apr/17 ] |
|
You are correct that the current implementation of Any is to attempt to read 1 document from the server and see whether it gets one back or not. This does indeed throw an exception if the document that comes back from the server happens to be bad in some way that causes deserialization to thrown an exception. This could be implemented using some other query that did not involve client side deserialization of the document. You are welcome to submit a pull request if you come up with an alternative implementation. |
| Comment by Viktor Svyatokha [ 07/Apr/17 ] |
|
I can start fixing this bug but I need an approval from driver team |