<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:43:46 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-2876] Expose the API for creation of implicit client sessions</title>
                <link>https://jira.mongodb.org/browse/CSHARP-2876</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;As far as this question at mongodb-user &amp;#8211;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/mongodb-user/c7Do8xYftpg&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://groups.google.com/forum/#!topic/mongodb-user/c7Do8xYftpg&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;has no answer, and to my knowledge, C# driver keeps creation of implicit sessions to itself (and uses them effectively).&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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).&lt;/p&gt;

&lt;p&gt;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, &quot;officially&quot;.&lt;/p&gt;

&lt;p&gt;Use of MongoClient.StartSession() was my first attempt but it turned out to be only half working.&#160;Per this bug report &amp;#8211;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/nightroman/Mdbc/issues/33&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/nightroman/Mdbc/issues/33&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;not all servers support this way.&lt;/p&gt;

&lt;p&gt;Thus, for the moment I decided to call the internal driver method using reflection. It&apos;s a hack indeed but it keeps my code clean and simple.&lt;/p&gt;

&lt;p&gt;I hope, one way or another, the driver exposes the API for implicit sessions and the hack goes.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1055249">CSHARP-2876</key>
            <summary>Expose the API for creation of implicit client sessions</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13202">Works as Designed</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="nightroman">Roman Kuzmin</reporter>
                        <labels>
                    </labels>
                <created>Sun, 15 Dec 2019 15:50:48 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:54 +0000</updated>
                            <resolved>Tue, 14 Jan 2020 14:17:06 +0000</resolved>
                                    <version>2.10.0</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="2732229" author="nightroman" created="Wed, 15 Jan 2020 17:56:22 +0000"  >&lt;p&gt;Should I open another issue with suggestion to allow null session parameters, what do you think?&lt;/p&gt;

&lt;p&gt;Does it look reasonable or hopeless?&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;I think sooner or later, when people start to use transactions often enough, the current design will show its inconvenience and the issues will be opened anyway. Now, any function with a session parameter has to call every driver function using this inconvenient and error prone pattern `if (session == null) { result = collection.Do(x, y, z); } else { result = collection.Do(session, x, y, z); }`.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="2724551" author="nightroman" created="Tue, 14 Jan 2020 15:45:57 +0000"  >&lt;p&gt;Let me put it this way. Your suggestion:&lt;/p&gt;

&lt;p&gt;&amp;gt;&#160;It would probably be better to call the overloads without a session parameter when you don&apos;t have a session...&lt;/p&gt;

&lt;p&gt;But what is &quot;don&apos;t have a session&quot;? It is null versus not null. The driver does not provide any other alternative for this. At the same time it does not allow the session parameter to be null. This leads to some inconveniences in using the API.&lt;/p&gt;</comment>
                            <comment id="2724429" author="nightroman" created="Tue, 14 Jan 2020 15:07:57 +0000"  >&lt;p&gt;Thank you, I understand.&lt;/p&gt;

&lt;p&gt;Can you consider alternatives?&lt;br/&gt;
 For example allow the session parameter to be null? Assuming some internal implicit session or no session, it&apos;s up to the driver.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Or, for another example, expose another really dummy session type if the approach with null parameter is against some guidelines, style, preferences.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="2724327" author="rstam" created="Tue, 14 Jan 2020 14:16:52 +0000"  >&lt;p&gt;I understand where you&apos;re coming from but I&apos;m concerned about making `StartImplicitSession` public.&lt;/p&gt;

&lt;p&gt;Implicit sessions are intended for internal use only. If we were to let implicit sessions leak out of the driver by making `StartImplicitSession` public we would have to worry about applications unintentionally using implicit sessions in ways that are not allowed (like calling `StartTransaction` on an implicit session etc...).&lt;/p&gt;

&lt;p&gt;It would probably be better to call the overloads without a session parameter when you don&apos;t have a session, though I understand that&apos;s a bit tedious. But it should perform slightly better than calling `StartImplicitSession` using reflection and doesn&apos;t rely on internal implementation details like implicit sessions.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hvzhs7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>