[CSHARP-1719] Selecting from a IMongoQueryable collection with a Linq Expression throws an error because of 'Id' property Created: 21/Jul/16  Updated: 09/Nov/22  Resolved: 09/Nov/22

Status: Closed
Project: C# Driver
Component/s: Linq, Serialization
Affects Version/s: 2.2.4
Fix Version/s: 2.3

Type: Bug Priority: Major - P3
Reporter: Florent BROUCA Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 64bits


Attachments: Zip Archive CSHARP-1719-Regression.zip     Text File bug.cs    
Issue Links:
Related
related to CSHARP-1555 Projecting from and to the same type ... Closed
Backwards Compatibility: Fully Compatible

 Description   

Using the mongoDb c# driver 2.2.4, selecting from a IMongoQueryable collection with a Linq Expression throws an error because of my Id field.

The exception thrown is 'Element 'Id' does not match any field or property of class MongoDbHierarchicalStoring.Man.'

You can find more info on the stackoverflow post: http://stackoverflow.com/questions/38508622/selecting-from-a-imongoqueryable-collection-with-a-linq-expression-throws-an-err

If I change my 'Id' property and rename it '_id', it worked. But in a prior version of the driver (2.1.1) it used to work fine.
The sample you can find in the attached file proves it : testing with the old version of the driver retrieves the data where as the new version throws an exception.



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

Works in both LINQ2 and LINQ3 with the latest driver.

Comment by Jeffrey Yemin [ 28/Oct/17 ]

Ping rstam

Comment by Robert Stam [ 20/Dec/16 ]

I can reproduce this against 2.4.0 with the code you provided.

It's not so much a regression as a new scenario that the original fix didn't contemplate.

The original fix was for LINQ expressions. Your sample code is using the fluent aggregate API.

Comment by James Kovacs [ 07/Oct/16 ]

There appears to be a regression. In C# Driver 2.4.0-beta1, the attached code, CSHARP-1719-Regression.zip, results in the error "Element 'Id' does not match any field or property of class ConsoleApplication.Root." Built on OSX Sierra using .NET Core 1.0.0-preview2-003131. Renaming `CSharp1719.Id` to `CSharp1719._id` causes the code to run without throwing the exception.

Comment by Githook User [ 10/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1719: supporting projections into identity type.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/ad81ac6e3781931fb6d2240e6100d1c03d8c375f

Comment by Githook User [ 10/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1719: supporting projections into identity type.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/ad81ac6e3781931fb6d2240e6100d1c03d8c375f

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