Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2876

Expose the API for creation of implicit client sessions

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.10.0
    • Component/s: API
    • None

      As far as this question at mongodb-user –

      https://groups.google.com/forum/#!topic/mongodb-user/c7Do8xYftpg

      has no answer, and to my knowledge, C# driver keeps creation of implicit sessions to itself (and uses them effectively).

      In my scenarios it would be useful, clean and less error prone to create such sessions in order to avoid numerous code forks on calling driver methods. Namely, I would like to always have a session, either provided by a higher level caller or implicit created when the caller provides none.

      In this case, I can always call the driver methods with the session parameter instead of checking the session for null and calling two methods (one depending on the check result).

      As far as I can see in the sources, the driver methods without parameters create implicit sessions and call their twin methods with this parameter. In a way, I would like to be able to do this as well, "officially".

      Use of MongoClient.StartSession() was my first attempt but it turned out to be only half working. Per this bug report –

      https://github.com/nightroman/Mdbc/issues/33

      not all servers support this way.

      Thus, for the moment I decided to call the internal driver method using reflection. It's a hack indeed but it keeps my code clean and simple.

      I hope, one way or another, the driver exposes the API for implicit sessions and the hack goes.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            nightroman Roman Kuzmin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: