<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:48:49 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-4625] Find Method on collection object is not working. Saying &apos;MongoDB.Driver.MongoCollectionBase&lt;MongoDB.Bson.BsonDocument&gt;&apos; does not contain a definition for &apos;Find&apos;</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4625</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;h4&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;Summary&lt;/h4&gt;

&lt;p&gt;Find Method on collection object is not working. Saying &apos;MongoDB.Driver.MongoCollectionBase&amp;lt;MongoDB.Bson.BsonDocument&amp;gt;&apos; does not contain a definition for &apos;Find&apos;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Pleaseprovidetheversionofthedriver.Ifapplicable%2CpleaseprovidetheMongoDBserverversionandtopology%28standalone%2Creplicaset%2Corshardedcluster%29.&quot;&gt;&lt;/a&gt;Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).&lt;/h4&gt;

&lt;p&gt;Driver version ---&amp;gt;&#160; 2.19.1&lt;br/&gt;
we are using &lt;b&gt;Azure Cosmos DB for MongoDB account(RU)&lt;/b&gt; and server version &lt;b&gt;4.2&lt;/b&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;HowtoReproduce&quot;&gt;&lt;/a&gt;How to Reproduce&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;1. create Azure cosmost DB for MongoDB account(RU). version should be 4.2&lt;/em&gt;&lt;br/&gt;
&lt;em&gt;2. create a sample db and collection name.&lt;/em&gt;&lt;br/&gt;
&lt;em&gt;3. do write the following similar code,&lt;/em&gt;&lt;br/&gt;
&#160;__&#160;&lt;br/&gt;
&lt;em&gt;using MongoDB.Driver;&lt;/em&gt;&lt;br/&gt;
&lt;em&gt;using MongoDB.Bson;&lt;/em&gt;&lt;br/&gt;
var client = new MongoClient(connectionString);&lt;br/&gt;
var database = client.GetDatabase(&quot;teacher_profile&quot;);&lt;br/&gt;
var collection = database.GetCollection&amp;lt;BsonDocument&amp;gt;(&quot;chapters&quot;);&lt;br/&gt;
var filter = Builders&amp;lt;BsonDocument&amp;gt;.Filter.Eq(&quot;_id&quot;, ObjectId.Parse(&quot;64439214f877fcad42b31c38&quot;));&lt;br/&gt;
&#160;var result = collection.Find(filter).FirstOrDefault();&lt;br/&gt;
&#160;Console.WriteLine(result);&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;AdditionalBackground&quot;&gt;&lt;/a&gt;Additional Background&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Please provide any additional background information that may be helpful in diagnosing the bug.&lt;/em&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2321632">CSHARP-4625</key>
            <summary>Find Method on collection object is not working. Saying &apos;MongoDB.Driver.MongoCollectionBase&lt;MongoDB.Bson.BsonDocument&gt;&apos; does not contain a definition for &apos;Find&apos;</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</type>
                                            <priority id="5" iconUrl="https://jira.mongodb.org/images/icons/priorities/trivial.svg">Trivial - P5</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="punnammani@gmail.com">manikanta punnam</reporter>
                        <labels>
                    </labels>
                <created>Sat, 22 Apr 2023 08:55:57 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:37 +0000</updated>
                            <resolved>Mon, 1 May 2023 17:52:16 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="5391590" author="rstam" created="Mon, 1 May 2023 17:51:58 +0000"  >&lt;p&gt;If you choose not to use var and instead choose to (or need to) declare the type explicitly I recommend you use `IMongoColection&amp;lt;TDocument&amp;gt;` as the type of the variable.&lt;/p&gt;</comment>
                            <comment id="5372801" author="JIRAUSER1273551" created="Tue, 25 Apr 2023 07:48:32 +0000"  >&lt;p&gt;I found what was the problem.&lt;/p&gt;

&lt;p&gt;In the above code, I have not declared the collection object before assigning the result of &lt;b&gt;database.GetCollection&amp;lt;BsonDocument&amp;gt;(&quot;chapters&quot;);&lt;/b&gt;&#160;&lt;br/&gt;
If i follow this approach it assigning the &quot;CollectionBase&amp;lt;BsonDocument&amp;gt;&quot; type to &quot;collection&quot; object. As a result getting the above mentioned error.&lt;/p&gt;

&lt;p&gt;But when i declared the collection variable with &quot;IMongoCollection&amp;lt;BsonDocument&amp;gt;&quot; type before doing assignment like below, it starts working.&lt;/p&gt;

&lt;p&gt;private static IMongoCollection&amp;lt;BsonDocument&amp;gt; collection;&lt;br/&gt;
collection = database.GetCollection&amp;lt;BsonDocument&amp;gt;(&quot;chapters&quot;);&lt;/p&gt;


&lt;p&gt;I am new to statically typed languages like C#. I am not sure if this is an issue or not in this case.&lt;/p&gt;

&lt;p&gt;Please rectify if that is the case.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</comment>
                            <comment id="5368945" author="rstam" created="Sun, 23 Apr 2023 21:45:09 +0000"  >&lt;p&gt;I tried to reproduce the error you described and did not get an error.&lt;/p&gt;

&lt;p&gt;Note that the MongoCollectionBase class mentioned in your error message is an internal implementation detail. None of our public APIs return a value of type MongoCollectionBase. The call to database.GetCollection&amp;lt;BsonDocument&amp;gt; returns a value of type IMongoCollection&amp;lt;BsonDocument&amp;gt;, and the Find method is an extension method on IMongoCollection.&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_14266" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Documentation Changes Summary</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;1.  What would you like to communicate to the user about this feature?&lt;br/&gt;
2.  Would you like the user to see examples of the syntax and/or executable code and its output?&lt;br/&gt;
3.  Which versions of the driver/connector does this apply to?&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr48xi:oasvyki</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>