<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36: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-468] Any() query on subdocument inside of Where() throws exception</title>
                <link>https://jira.mongodb.org/browse/CSHARP-468</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Given these entities:&lt;/p&gt;

&lt;p&gt;public class Person&lt;br/&gt;
{&lt;br/&gt;
    public Guid Id &lt;/p&gt;
{ get; set; }&lt;br/&gt;
    public string Name { get; set; }
&lt;p&gt;    public List&amp;lt;Address&amp;gt; Addresses &lt;/p&gt;
{ get; set; }&lt;br/&gt;
}&lt;br/&gt;
&lt;br/&gt;
public class Address&lt;br/&gt;
{&lt;br/&gt;
    public string Street { get; set; }
&lt;p&gt;    public string City &lt;/p&gt;
{ get; set; }&lt;br/&gt;
    public string State { get; set; }
&lt;p&gt;    public string Zip &lt;/p&gt;
{ get; set; }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;This query does not work: (people = MongoCollection&amp;lt;Person&amp;gt;)&lt;br/&gt;
people.AsQueryable().Where(p =&amp;gt; p.Addresses.Any(a =&amp;gt; a.State == &quot;NY&quot;)).ToList()&lt;/p&gt;

&lt;p&gt;It would be the equivalent of this query in the shell:&lt;br/&gt;
db.people.find(&lt;/p&gt;
{&quot;Addresses.State&quot;:&quot;NY&quot;}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;The exception thrown is:&lt;br/&gt;
Unhandled Exception: System.NotSupportedException: Enumerable.Any with a predicate is not supported.&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.BuildAnyQuery(MethodCallExpression methodCallExpression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 262&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.BuildMethodCallQuery(MethodCallExpression methodCallExpression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 695&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.BuildQuery(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 832&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.BuildQuery() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 123&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.Execute() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 132&lt;br/&gt;
   at MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryProvider.cs:line 147&lt;br/&gt;
   at MongoDB.Driver.Linq.MongoQueryable`1.GetEnumerator() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryable.cs:line 81&lt;br/&gt;
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)&lt;br/&gt;
   at System.Linq.Enumerable.ToList&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;br/&gt;
   at ConsoleApplication5.Program.Main(String[] args) in C:\Projects\ConsoleApplication5\ConsoleApplication5\Program.cs:line 55&lt;/p&gt;


&lt;p&gt;For now, I am using the Inject() workaround, however this type of query I believe needs to be supported.&lt;/p&gt;</description>
                <environment></environment>
        <key id="38255">CSHARP-468</key>
            <summary>Any() query on subdocument inside of Where() throws exception</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="3">Duplicate</resolution>
                                        <assignee username="craig.wilson@mongodb.com">Craig Wilson</assignee>
                                    <reporter username="rhoffman">Ryan Hoffman</reporter>
                        <labels>
                    </labels>
                <created>Wed, 9 May 2012 17:18:22 +0000</created>
                <updated>Thu, 20 Mar 2014 14:33:57 +0000</updated>
                            <resolved>Wed, 9 May 2012 17:24:30 +0000</resolved>
                                    <version>1.4.2</version>
                                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="117743" author="craiggwilson" created="Wed, 9 May 2012 17:23:32 +0000"  >&lt;p&gt;This is scheduled for the 1.5 release and will result in an $elemMatch element getting generated.&lt;/p&gt;</comment>
                            <comment id="117740" author="rhoffman" created="Wed, 9 May 2012 17:21:36 +0000"  >&lt;p&gt;Another way to express this query is:&lt;br/&gt;
people.AsQueryable().Where(p =&amp;gt; p.Addresses.Where(a =&amp;gt;  a.State == &quot;NY&quot;).Any()).ToList();&lt;/p&gt;

&lt;p&gt;This fails with this exception:&lt;br/&gt;
Unhandled Exception: System.ArgumentException: Unsupported where clause: Enumerable.Any&amp;lt;Address&amp;gt;(Enumerable.Where&amp;lt;Address&amp;gt;(p.Addresses, (Address a) =&amp;gt; (a.State == &quot;NY&quot;))).&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.BuildQuery(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 862&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.BuildQuery() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 123&lt;br/&gt;
   at MongoDB.Driver.Linq.SelectQuery.Execute() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 132&lt;br/&gt;
   at MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryProvider.cs:line 147&lt;br/&gt;
   at MongoDB.Driver.Linq.MongoQueryable`1.GetEnumerator() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryable.cs:line 81&lt;br/&gt;
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)&lt;br/&gt;
   at System.Linq.Enumerable.ToList&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;br/&gt;
   at ConsoleApplication5.Program.Main(String[] args) in C:\Projects\ConsoleApplication5\ConsoleApplication5\Program.cs:line 55&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="33298">CSHARP-413</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </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|hrh7k7:</customfieldvalue>

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