C# lost session associated

In your manual

write about if get database from session its retrive database with the session

I also get database from session but transaction dont work. what is problem ?

 var _client = new MongoClient("mongodb://localhost");
 using (var session = _client.StartSession())
        var col = session.Client.GetDatabase("a").GetCollection<c>("c");
        var m = new MyClass {  };

Here we see that the collection seems to be working with its own session. Ignored session and transaction.

I don’t understand is this a driver bug or an error in the manual? Or is there really no other way to add a session to a parameter in every query?

    col.InsertOne(session, m);

Hey, yes, you should provide a session to each method where you want to use transaction/session related logic

1 Like

And then what is said in the above paragraph from the manual?

it’s about mongosh. c# driver has different behavior related to passing sessions

1 Like