<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:41:38 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-2110] Discriminator of the query of sub typed collections is incorrect</title>
                <link>https://jira.mongodb.org/browse/CSHARP-2110</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I have following scenario:&lt;/p&gt;

&lt;p&gt;I&apos;m using the the Mongo C# Driver with CosmosDB and I use a single collection to store different document types. I not really happy with this, but it seems recommended by Microsoft.&lt;/p&gt;

&lt;p&gt;I get the collection:&lt;/p&gt;

&lt;p&gt;_collection = database.GetCollection&amp;lt;object&amp;gt;(&quot;shared&quot;).OfType&amp;lt;T&amp;gt;();&lt;/p&gt;

&lt;p&gt;When I insert a document the document the configured discriminator is used&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Works:&lt;/b&gt;&lt;br/&gt;
_collection.InsertOne(document);&lt;br/&gt;
_collection.Find(filter).SingleOrDefault();&lt;/p&gt;

&lt;p&gt;But when I try to query the collection the discriminator is always &quot;FullTypeName, Assemby&quot;. &lt;/p&gt;

&lt;p&gt;&lt;b&gt;Doesn&apos;t work:&lt;/b&gt;&lt;br/&gt;
_collection.AsQueryable().ToList()&lt;/p&gt;

&lt;p&gt;So the configured discriminator value is never used.&lt;/p&gt;

&lt;p&gt;Currently it works by setting to discriminator to the value used by the query.&lt;/p&gt;

&lt;p&gt;//does not support nested types&lt;br/&gt;
classMapInitializer.SetDiscriminator(typeof(T).FullName + &quot;, &quot; + typeof(T).Assembly.GetName().Name);&lt;/p&gt;

&lt;p&gt;But we like to give a more functional names to the discriminator which don&apos;t break if we refactor. &lt;/p&gt;

&lt;p&gt;I had a quick look and it seems that the filter of the OfTypeMongoCollection is not passed to the MongoQueryableImpl. And to can probably solved using a default expression that filters on the configured discriminator type.&lt;/p&gt;

&lt;p&gt;Is this something that need to be supported by the library? &lt;/p&gt;

&lt;p&gt;Any feedback is appriciated!&lt;/p&gt;

&lt;p&gt;Tim&lt;/p&gt;</description>
                <environment></environment>
        <key id="463290">CSHARP-2110</key>
            <summary>Discriminator of the query of sub typed collections is incorrect</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="9">Done</resolution>
                                        <assignee username="wan.bachtiar@mongodb.com">Wan Bachtiar</assignee>
                                    <reporter username="tcools">T Cools</reporter>
                        <labels>
                    </labels>
                <created>Thu, 23 Nov 2017 12:33:54 +0000</created>
                <updated>Mon, 15 Nov 2021 22:25:24 +0000</updated>
                            <resolved>Thu, 25 Jun 2020 02:28:05 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="3223175" author="rachelle.palmer" created="Thu, 25 Jun 2020 02:28:05 +0000"  >&lt;p&gt;Hi there, thank you for reaching out to MongoDB. As this sounds more like a support issue, I wanted to give you some resources to get this question answered more quickly:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;our MongoDB support portal, located at &lt;a href=&quot;https://support.mongodb.com/welcome&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;support.mongodb.com&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;our MongoDB community forums, located &lt;a href=&quot;https://developer.mongodb.com/community/forums/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;If you are an Atlas customer, there is free support offered 24/7 in the lower right hand corner of the UI.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Thank you!&lt;br/&gt;
Rachelle&lt;/p&gt;</comment>
                            <comment id="2247010" author="james@turnersoftware.com.au" created="Wed, 15 May 2019 07:12:21 +0000"  >&lt;p&gt;This sounds very much like &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-1907&quot; title=&quot;Type discriminators don&amp;#39;t work when collection document type is an interface&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-1907&quot;&gt;CSHARP-1907&lt;/a&gt; with discriminators not being handled consistently.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                    </comments>
                    <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|htcenb:</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>