[CSHARP-3197] Make applying SelectSelectCombiningTransformer on expressions optional Created: 24/Aug/20  Updated: 27/Oct/23  Resolved: 01/Nov/22

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

Type: Improvement Priority: Major - P3
Reporter: Hesam Faridmehr Assignee: Robert Stam
Resolution: Works as Designed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In some cases when we are building dynamic expressions, it is possible to end up using multiple projections, for example:

 

queryable.Select(i => new { A = i.Age }).Select(i => new { B = i.A})

Applying SelectSelectCombiningTransformer make this LINQ to be combined and end up in NotSupportedException.

I removed the transformer and there was no side effects, just two of tests were failed which excepted the exact query. 

Here are name of the tests:

 

Largest_and_smallest_cities_by_state
Largest_and_smallest_cities_by_state_queryable_syntax

If we could make usage of this transformer optional, it will cover more situations.

 

 

 



 Comments   
Comment by Hesam Faridmehr [ 01/Nov/22 ]

Great, thanks

Comment by Robert Stam [ 01/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 Githook User [ 01/Nov/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-3197: Verify that Select/Select works in LINQ3.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6f78ff0df4dc1e0abeb4f79c616ce87e3dc60535

Comment by Esha Bhargava [ 14/Sep/20 ]

faridmehr.hesam@gmail.com Thanks for reporting this issue. We are in the process of a major redesign of our LINQ provider and will consider this as a part of that effort.

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