[CSHARP-4368] Support Convert to BsonValue in LINQ3 Created: 15/Oct/22  Updated: 28/Oct/23  Resolved: 03/Nov/22

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: 2.18.0
Fix Version/s: 2.19.0

Type: Bug Priority: Unknown
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CSHARP-4331 Make LINQ3 the default LinqProvider Closed
is depended on by CSHARP-4358 Update tests that only test against L... Closed

 Description   

Conversions to BsonValue are not supported in LINQ3. This was first discovered when running the test named `Bucket_typed_should_return_expected_result` against LINQ3.

But it is more simply reproduceable:

public class C
{
    public int Id { get; set; }
    public int I { get; set; }
}
 
[Fact]
public void Convert_to_BsonValue_should_work()
{
    var client = DriverTestConfiguration.Linq3Client;
    var database = client.GetDatabase("test");
    var collection = database.GetCollection<C>("test");    
 
    var queryable = collection.AsQueryable().Select(x => new { V = (BsonValue)x.I });    
 
    var pipeline = queryable.ToString();
}
 

 



 Comments   
Comment by Githook User [ 03/Nov/22 ]

Author:

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

Message: CSHARP-4368: Support Convert to BsonValue in LINQ3.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6fd8f4b905af949ed74fefeddd626feb996562b3

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