[CSHARP-3237] NotSupportedException when using ToList on Embedded Documents Created: 23/Oct/20 Updated: 28/Oct/23 Resolved: 15/Nov/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | None |
| Fix Version/s: | 2.18.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Mohamad Javad Ebrahimi | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
| Comments |
| Comment by Robert Stam [ 15/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
| ||||||||||||||
| Comment by Esha Bhargava [ 09/Nov/20 ] | ||||||||||||||
|
We are working on a new LINQ provider and we will look at supporting this feature in the context of that project. | ||||||||||||||
| Comment by Mohamad Javad Ebrahimi [ 01/Nov/20 ] | ||||||||||||||
|
Thank you for your workaround but do you have a plan to solve this problem in the future? | ||||||||||||||
| Comment by Robert Stam [ 28/Oct/20 ] | ||||||||||||||
|
A temporary workaround could be to move the call to `ToList` so that it executes client-side:
Everything after `AsEnumerable` runs client-side.
| ||||||||||||||
| Comment by Mohamad Javad Ebrahimi [ 28/Oct/20 ] | ||||||||||||||
|
Thank you for replying. Changing type solves this issue but according to our team contracts, we have to use List<T> instead of IEnumerable<T> for these situations. | ||||||||||||||
| Comment by Robert Stam [ 26/Oct/20 ] | ||||||||||||||
|
I can confirm that this is reproducible. We don't support ToList here. I had to assume some type of Post class to reproduce this. I used:
May I ask why you want to call ToList here? Why not just omit it?
The only difference is the type of the Comments property (IEnumerable<string> instead of List<string>)? |