[CSHARP-1022] FindAndModify() method via C# driver fails if a field contains an array of complex types Created: 04/Aug/14  Updated: 13/Oct/17  Resolved: 13/Oct/17

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

Type: Bug Priority: Major - P3
Reporter: DannyVarod [X] Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

.NET


Backwards Compatibility: Fully Compatible

 Description   

Calling FindAndModify() method when one or more of the fields in the Update options contains an array with one or more non-primitive object (e.g. an object with two string properties) cause exception with message:

.NET type MySubType cannot be mapped to a BsonValue.

Similar closed bugs (same problem in other methods):
https://jira.mongodb.org/browse/CSHARP-198
https://jira.mongodb.org/browse/CSHARP-236



 Comments   
Comment by Robert Stam [ 26/Apr/17 ]

This bug was submitted against version 1.9.1, which is no longer supported.

While we wouldn't fix this bug for 1.9.1, I would like to reproduce it so that I can ensure that the current version of the driver do not have this issue.

I probably haven't interpreted the English description of the scenario correctly when attempting to reproduce...

Comment by Robert Stam [ 26/Apr/17 ]

Sorry for the long delay in looking at this.

I am unable to reproduce this.

I used these classses:

public class C
{
    public int Id { get; set; }
    public D D { get; set; }
}
 
public class D
{
    public E[] EA { get; set; }
}
 
public class E
{
    public string S { get; set; }
    public string T { get; set; }
}

and this code to call FindAndModify:

var result = collection.FindAndModify(new FindAndModifyArgs
{
    Query = Query<C>.EQ(c => c.Id, 1),
    Update = Update<C>.Set(c => c.D, new D { EA = new[] { new E { S = "x", T = "y" } } })
});

And it all worked fine.

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