Exception occur while Mongodb Upgradation from 2.13.2 to 2.19.0

We are currently using ongoDB.Driver" Version=“2.13.2” and trying to upgrade to ongoDB.Driver" Version=“2.19.0”. we are using old mongodb bason query’s in this application.
After upgrading the below lines throw exception.
var result = await _collection.FindAsync(filter,option).Result.ToListAsync();
throw exception:
" When called from ‘VisitListInit’,
rewriting a node of type ‘System.Linq.Expressions.NewExpression’
must return a non-null value of the same type.
Alternatively, override ‘VisitListInit’ and change it to not visit children of this type.’ while upgrade the mongodb driver 2.19.0"
cloud you please help me to fix it without changing the existing code,
we are using .net5

Hi, @Athira_K_S,

Welcome to the MongoDB Community Forums.

I see that you’ve encountered a LINQ error when running a Fluent Find operation. Although this isn’t a LINQ query, internally the driver uses the LINQ machinery to translate expressions (e.g. x => x.Price > 42) into MQL. In 2.19.0, we switched from our existing LINQ2 provider to the new, improved LINQ3 provider - which is likely what is causing the problem. You can switch back to the LINQ2 provider using code similar to the following:

var connectionString = "mongodb://localhost";
var clientSettings = MongoClientSettings.FromConnectionString(connectionString);
clientSettings.LinqProvider = LinqProvider.V2;
var client = new MongoClient(clientSettings);

It would be helpful if you could file a bug with a repro here so that we could investigate and resolve the issue. Thanks in advance!


Thank You James_Kovacs ,
Its work for me