[CSHARP-1761] LINQ join throws exception on the whole document projection Created: 06/Sep/16  Updated: 04/Feb/22  Resolved: 04/Feb/22

Status: Closed
Project: C# Driver
Component/s: Linq, LINQ3
Affects Version/s: 2.2.4, 2.3.0-beta1
Fix Version/s: 2.14.0

Type: Bug Priority: Major - P3
Reporter: Vyacheslav Stroy Assignee: James Kovacs
Resolution: Done Votes: 4
Labels: triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: CSHARP-3615

 Description   

I'm getting NotSupportedException ($project or $group does not support {document}) on very simple join statement:

from s in collection1
join r in collection2 on s.ForeignKey equals r.Id
select s

But everything works great when objects from another collection are projected.

from s in collection1
join r in collection2 on s.ForeignKey equals r.Id
select r

It seems that query translator can't parse document expression.



 Comments   
Comment by James Kovacs [ 04/Feb/22 ]

This issue has been fixed in the new LINQ provider (known as LINQ3), which is included 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 Pascal [ 29/Jan/18 ]

I'm having the same issue. This is blocking one of the main architecture components of our solution...

The issue has not been updated in a while and the bug was reported more than a year ago, can we get an update?

Comment by Giuliano Barberi [ 01/May/17 ]

This is still an issue on 2.4.3. It makes doing a $match/$project/$replaceRoot pipeline in order to compare two fields and get back the original document impossible afaik. Any idea when this will be supported?

Comment by Riccardo Poli [ 08/Oct/16 ]

need this problem fixed too, same problem with 2.3.0

Comment by Craig Wilson [ 06/Sep/16 ]

Yes, you're right. I meant to indicate our next release. I believe 2.4 will likely be our next release, prior to 2.3.1. However, if we do release 2.3.1, we'll try and include it.

Craig

Comment by Vyacheslav Stroy [ 06/Sep/16 ]

I've tried already both

select new { s }

and

select new { temp = s }

Neither works. Error is the same.

I understand that you have a lot of issues in 2.3.0 already, but please consider planning this fix in 2.3.1 release. This case is simple, however some queries with joins on 3+ collections just can't be done at all. It's sort of critical for me.

Thanks,
Vyacheslav

Comment by Craig Wilson [ 06/Sep/16 ]

Ok. It's a bit late in the release cycle for 2.3 to get this fixed.

I believe a workaround might be to project into an anonymous type: select new

{ s }

. Then you can just suck it out. If that works, please let us know. I'll put this on the books for 2.4 timeframe.

Craig

Comment by Vyacheslav Stroy [ 06/Sep/16 ]

Hi Craig,

I've tried with 2.3.0-rc1 binaries and even with sources form the master branch. Result is the same.

Comment by Craig Wilson [ 06/Sep/16 ]

Hi Vyacheslav,

Could you please try with 2.3.0-rc1? We've fixed a potential issue related to this already.

Craig

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