<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:48:02 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-4370] Exception in .Where() matching Id</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4370</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;Hi,&lt;/p&gt;

&lt;p&gt;I&apos;m getting an exception with simple filtering on ObjectId represented as string inside a C# class. &lt;/p&gt;

&lt;p&gt;Exception:&lt;br/&gt;
MongoDB.Driver.Linq.ExpressionNotSupportedException: &apos;Expression not supported: x.SomeId in (x.SomeId == &quot;634cf4c86a1bde31017xxxxx&quot;) because field &quot;SomeId&quot; is not represented as a string.&apos;&lt;/p&gt;

&lt;p&gt;Call:&lt;br/&gt;
someCollection.AsQueryable(options)&lt;br/&gt;
                .Where(x =&amp;gt; x.SomeId == &quot;634cf4c86a1bde31017xxxxx&quot;);&lt;/p&gt;

&lt;p&gt;Property in the class:&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)&amp;#93;&lt;/span&gt;&lt;br/&gt;
  public string SomeId { get; set; }&lt;/p&gt;

&lt;p&gt;It works with LinqProvider V2.&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;2.18.0&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;Call AsQueryable with Where() filtering on objectId as string property inside a class.&lt;/p&gt;


&lt;p&gt;Thank you!&lt;/p&gt;</description>
                <environment></environment>
        <key id="2160118">CSHARP-4370</key>
            <summary>Exception in .Where() matching Id</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</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="dimitri.kroo@baramundi.com">Dimitri Kroo</reporter>
                        <labels>
                    </labels>
                <created>Mon, 17 Oct 2022 08:47:55 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:40 +0000</updated>
                            <resolved>Tue, 18 Oct 2022 19:08:26 +0000</resolved>
                                    <version>2.18.0</version>
                                                    <component>LINQ3</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4924143" author="xgen-internal-githook" created="Mon, 24 Oct 2022 23:53:59 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;rstam&apos;, &apos;email&apos;: &apos;robert@robertstam.org&apos;, &apos;username&apos;: &apos;rstam&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-4370&quot; title=&quot;Exception in .Where() matching Id&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-4370&quot;&gt;&lt;del&gt;CSHARP-4370&lt;/del&gt;&lt;/a&gt;: Confirm that sample code works with LINQ3.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/commit/b8756bc803b8fb91550f25a9878214ad18fed958&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/commit/b8756bc803b8fb91550f25a9878214ad18fed958&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4910722" author="rstam" created="Tue, 18 Oct 2022 19:07:59 +0000"  >&lt;p&gt;Thanks for letting us know that it is working for you.&lt;/p&gt;</comment>
                            <comment id="4908958" author="JIRAUSER1257713" created="Tue, 18 Oct 2022 07:06:39 +0000"  >&lt;p&gt;Thank you for support! My bad... It was a class without &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)&amp;#93;&lt;/span&gt;. Somebody forgot to add the attribute and it was working with V2. V3 is stricter I guess.&lt;/p&gt;

&lt;p&gt;Best regards&lt;br/&gt;
Dimitri&lt;/p&gt;</comment>
                            <comment id="4908665" author="rstam" created="Tue, 18 Oct 2022 00:26:53 +0000"  >&lt;p&gt;I attempted to reproduce this and for me it worked correctly.&lt;/p&gt;

&lt;p&gt;You can see my repro on the following branch and compare to see if I am doing anything differently than you:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/rstam/mongo-csharp-driver/tree/csharp4370&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/rstam/mongo-csharp-driver/tree/csharp4370&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: there IS an `ExpressionNotSupportedException` thrown &lt;b&gt;internally&lt;/b&gt;, but it is deliberate and is caught and handled. If you have the debugger configured to stop when ANY exception is thrown (even if there is a catch handler for it) you might be seeing this internal exception.&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|i0wwqw:</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>