-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Summary
I've always relied on the driver's projection functionality using LINQ expressions. Before version 2.19.0, it worked well, selecting only those fields, that were used in the projection expression, translating known functions into the mongo functions, and doing client-side projections for the functions that were unable to be translated.
But now, in 2.19.0, I can no longer use functions that I want to run client-side. Let's say I have a BsonDocument collection and want to select only 2 fields, then I want to do a client-side projection using those 2 fields and my custom function. I used to just write:
var find = mongoCollection .Find(document => true) .Project(document => Functions.MyClientSideProjectionFunction(document["_key"], document["prop"]));
and it used to work well, but now, it fails with this error:
MongoDB.Driver.Linq.ExpressionNotSupportedException: Expression not supported: MyClientSideProjectionFunction(document.get_Item("_key"), document.get_Item("prop")).
You can't even make a tuple with those selected properties to map them later. ValueTuple.Create and Tuple.Create functions also fail.
This happens at the library level, so it doesn't matter which server configuration you use.
- depends on
-
CSHARP-4549 Support Tuple.Create and ValueTuple.Create in projections
- Closed
- duplicates
-
CSHARP-4498 .Project(c => c.Reference()) not work
- Closed
-
CSHARP-4763 Consider supporting client side projections with Find and Select in LINQ3
- Closed