<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39:55 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-1543] Query Lambdas: &quot;!a.b.Any()&quot; supported, but &quot;a.b.Any() == false&quot; fails</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1543</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Recently did a long overdue upgrade from 1.(something) to 2.2, and am having lots of trouble migrating my wrapper code across. One thing I&apos;m noticing is that lots of expressions I had been using previously (via linq) are simply not supported anymore, which is very odd to me. Could you clarify whether this is by design/known/etc?&lt;/p&gt;

&lt;p&gt;Works:&lt;br/&gt;
collection.Where(mydoc =&amp;gt; !mydoc.SomeListProperty.Any())&lt;/p&gt;

&lt;p&gt;Does not work:&lt;br/&gt;
collection.Where(mydoc =&amp;gt; mydoc.SomeListProperty.Any() == false)&lt;/p&gt;

&lt;p&gt;I will provide further info on other lambdas that are problematic, later.&lt;/p&gt;</description>
                <environment></environment>
        <key id="260191">CSHARP-1543</key>
            <summary>Query Lambdas: &quot;!a.b.Any()&quot; supported, but &quot;a.b.Any() == false&quot; fails</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="craig.wilson@mongodb.com">Craig Wilson</assignee>
                                    <reporter username="kevinza">Kevin Versfeld</reporter>
                        <labels>
                    </labels>
                <created>Fri, 22 Jan 2016 13:36:15 +0000</created>
                <updated>Thu, 6 Jul 2017 12:31:39 +0000</updated>
                            <resolved>Fri, 11 Mar 2016 20:37:31 +0000</resolved>
                                    <version>2.2</version>
                                    <fixVersion>2.2.4</fixVersion>
                                    <component>Linq</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="1201132" author="xgen-internal-githook" created="Fri, 11 Mar 2016 20:36:27 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;craiggwilson&apos;, u&apos;name&apos;: u&apos;Craig Wilson&apos;, u&apos;email&apos;: u&apos;craiggwilson@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-1543&quot; title=&quot;Query Lambdas: &amp;quot;!a.b.Any()&amp;quot; supported, but &amp;quot;a.b.Any() == false&amp;quot; fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-1543&quot;&gt;&lt;del&gt;CSHARP-1543&lt;/del&gt;&lt;/a&gt;: Fixed comparison of Any to a constant boolean.&lt;br/&gt;
Branch: v2.2.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/commit/5014111340c4a916b28059a9c89308cbbedcb7e7&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/commit/5014111340c4a916b28059a9c89308cbbedcb7e7&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1201131" author="xgen-internal-githook" created="Fri, 11 Mar 2016 20:35:44 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;craiggwilson&apos;, u&apos;name&apos;: u&apos;Craig Wilson&apos;, u&apos;email&apos;: u&apos;craiggwilson@gmail.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-1543&quot; title=&quot;Query Lambdas: &amp;quot;!a.b.Any()&amp;quot; supported, but &amp;quot;a.b.Any() == false&amp;quot; fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-1543&quot;&gt;&lt;del&gt;CSHARP-1543&lt;/del&gt;&lt;/a&gt;: Fixed comparison of Any to a constant boolean.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/commit/702aaffbf7152ccd212d412672c003b5bf4eb574&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/commit/702aaffbf7152ccd212d412672c003b5bf4eb574&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1169133" author="craiggwilson" created="Wed, 10 Feb 2016 13:43:23 +0000"  >&lt;p&gt;Hi, Kevin. &lt;/p&gt;

&lt;p&gt;The fix for it not working in LINQ is part of this ticket: &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-1521&quot; title=&quot;ElemMatch requires IBsonArraySerializer for DictionaryInterfaceImplementerSerializer&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-1521&quot;&gt;&lt;del&gt;CSHARP-1521&lt;/del&gt;&lt;/a&gt;. It will be released with version 2.3.0.&lt;/p&gt;

&lt;p&gt;We also currently don&apos;t have support for injecting FilterExpressions or other such things. We are really trying to get everything working with vanilla linq. At some point, we might need to do this, but I don&apos;t feel like we are there yet.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;
</comment>
                            <comment id="1167563" author="kevinza" created="Tue, 9 Feb 2016 08:28:28 +0000"  >&lt;p&gt;I&apos;m struggling with how to query a collection looking for documents which have particular values in an array (coming from a Dictionary originally). I believe &quot;ElemMatch&quot; is what I&apos;m after.&lt;br/&gt;
I used to use the Query helpers (with ElemMatch) to build a IMongoQuery (if I recall), and then inject it back into my LINQ (using the .Inject() method), but none of that works anymore. (I need it in LINQ form because I&apos;m doing a whole lot of other modifications to the IQueryable, sorting, limiting etc later on)  &lt;/p&gt;

&lt;p&gt;Anyway, documentation I think indicates I can do something like this to achieve ElemMatch:&lt;br/&gt;
collection.Where(doc =&amp;gt; doc.StringValues.Any(pair =&amp;gt; pair.Key == &quot;somekey&quot;)); - OR -&lt;br/&gt;
collection.Where(doc =&amp;gt; doc.StringValues.Any(pair =&amp;gt; pair.Key == &quot;somekey&quot; &amp;amp;&amp;amp; pair.Value == &quot;somevalue&quot;));&lt;/p&gt;

&lt;p&gt;But both of these just give me the error &lt;br/&gt;
&quot;The expression tree is not supported: &lt;/p&gt;
{document}
{sv}
&lt;p&gt;&quot;  &lt;br/&gt;
Note that &quot;sv&quot; is the mapped name of the property &quot;StringValues&quot;&lt;/p&gt;

&lt;p&gt;Is this something that should be working? Have I misunderstood? Is there still a way to use Inject? (I can post the error I get on that one, if necessary)&lt;/p&gt;

&lt;p&gt;I posted this in the User group, but no luck yet:&lt;br/&gt;
&lt;a href=&quot;https://groups.google.com/forum/#!topic/mongodb-user/1zXAJHVkcVQ&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://groups.google.com/forum/#!topic/mongodb-user/1zXAJHVkcVQ&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1156596" author="kevinza" created="Thu, 28 Jan 2016 14:39:00 +0000"  >&lt;p&gt;Gotcha, thanks.&lt;/p&gt;</comment>
                            <comment id="1156584" author="craiggwilson" created="Thu, 28 Jan 2016 14:32:46 +0000"  >&lt;p&gt;Yes, the final version you tried is the proper form for this. We removed the special &quot;ContainsAny&quot; extension method.&lt;/p&gt;</comment>
                            <comment id="1156428" author="kevinza" created="Thu, 28 Jan 2016 11:15:18 +0000"  >&lt;p&gt;Another one: I used to use this in much older versions of driver: &lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;collection.Where(doc =&amp;gt; doc.listOfIds.ContainsAny(someOtherList))&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;which no longer works.&lt;br/&gt;
I tried something like this:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;collection.Where(doc =&amp;gt; doc.listOfIds.Intersect(someOtherList).Any())&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;which also didn&apos;t work, and now use this (which does work):&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;collection.Where(doc =&amp;gt; someOtherList.Any(item =&amp;gt; doc.listOfIds.Contains(item)))&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Is this expected/correct?&lt;/p&gt;</comment>
                            <comment id="1151113" author="kevinza" created="Fri, 22 Jan 2016 14:13:40 +0000"  >&lt;p&gt;thanks for the super fast response Craig, I will do.&lt;/p&gt;</comment>
                            <comment id="1151102" author="craiggwilson" created="Fri, 22 Jan 2016 13:50:52 +0000"  >&lt;p&gt;All expressions &lt;b&gt;should&lt;/b&gt; work. Any that don&apos;t work are missing a test as the new linq parser passes the old test suite. Please push any more you find to this ticket and we&apos;ll tackle them all at once.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="401017">CSHARP-2012</issuekey>
        </issuelink>
                            </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|hshm5z:</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>