<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:54 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-462] Linq doesn&apos;t support &quot;In&quot; clause</title>
                <link>https://jira.mongodb.org/browse/CSHARP-462</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;public sealed class Document&lt;br/&gt;
{&lt;br/&gt;
    public string Id &lt;/p&gt;
{ get; set; }&lt;br/&gt;
    public List&amp;lt;string&amp;gt; Folders { get; set; }
&lt;p&gt;}&lt;br/&gt;
public sealed class Folder&lt;br/&gt;
{&lt;br/&gt;
   public string Id &lt;/p&gt;
{ get; set; }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;1. var documentFolders = documentCollection.AsQueryable().Where(x =&amp;gt; x.Id == &quot;document1&quot;).Select(x =&amp;gt; x.Folders).Single();&lt;br/&gt;
2. var folders = folderCollection.AsQueryable().Where(x =&amp;gt; documentFolders.Contains(x.Id)).ToArray();&lt;br/&gt;
3. Got this ArgumentException:&lt;br/&gt;
Unsupported where clause: System.Collections.Generic.List`1&lt;span class=&quot;error&quot;&gt;&amp;#91;System.String&amp;#93;&lt;/span&gt;.Contains(x.Id).&lt;/p&gt;

&lt;p&gt;Stack trace:&lt;/p&gt;


&lt;p&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.Linq.Buffer`1..ctor(IEnumerable`1 source)&lt;br/&gt;
   at System.Linq.Enumerable.ToArray&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;br/&gt;
   at DAL.MyService.MyMethod(String rId) in D:\file1.cs:line 176&lt;br/&gt;
   at DynamicModule.ns.Wrapped_INavigationServiceRepository_364d6b61519c4b838c96d681fbc90833.&amp;lt;GetObjectParents_DelegateImplementation&amp;gt;__1(IMethodInvocation inputs, GetNextInterceptionBehaviorDelegate getNext)&lt;/p&gt;






</description>
                <environment></environment>
        <key id="37723">CSHARP-462</key>
            <summary>Linq doesn&apos;t support &quot;In&quot; clause</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</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="craig.wilson@mongodb.com">Craig Wilson</assignee>
                                    <reporter username="gfx00">Brian</reporter>
                        <labels>
                    </labels>
                <created>Thu, 3 May 2012 09:39:53 +0000</created>
                <updated>Mon, 15 Nov 2021 16:28:41 +0000</updated>
                            <resolved>Wed, 9 May 2012 17:41:19 +0000</resolved>
                                    <version>1.4.2</version>
                                    <fixVersion>1.5</fixVersion>
                                                        <votes>3</votes>
                                    <watches>4</watches>
                                                                                                                                                            <comments>
                            <comment id="1816229" author="vdevappa@locusrobotics.com" created="Mon, 26 Feb 2018 18:13:58 +0000"  >&lt;p&gt;It is strange, but I got this error using contains with the 2.5 nuget package&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; (from p in collection.AsQueryable&amp;lt;MyClass&amp;gt;()&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                        where p.Property1 == id &amp;amp;&amp;amp;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                              p.Property2== &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                              list.Contains(p.Source) == &lt;/span&gt;&lt;span style=&quot;color: #006699; font-weight: bold; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;true&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                        select p).ToList();&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;The error is:&lt;/p&gt;

&lt;p&gt;2/26 5:32:01 PM&amp;gt;TID:18|CPU:34.81541|worker000000|worker000000$|Worker Service Fabric|error|DataGenerator::GenerateData()|LIN:0|********************************************************** ERROR: System.InvalidOperationException: Contains(value(System.Collections.Generic.List`1[System.Nullable`1&lt;span class=&quot;error&quot;&gt;&amp;#91;Locus.MongoDB.ClientWarehouse.ReportRequestSource&amp;#93;&lt;/span&gt;])) is not supported. at MongoDB.Driver.Linq.Translators.PredicateTranslator.GetFieldExpression(Expression expression) at MongoDB.Driver.Linq.Translators.PredicateTranslator.TranslateComparison(Expression variableExpression, ExpressionType operatorType, ConstantExpression constantExpression) at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.PredicateTranslator.TranslateAndAlso(BinaryExpression node) at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression node) at MongoDB.Driver.Linq.Translators.PredicateTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateWhere(WhereExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslatePipeline(PipelineExpression node) at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions) at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression) at MongoDB.Driver.Linq.MongoQueryableImpl`2.GetEnumerator() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source) at &lt;/p&gt;</comment>
                            <comment id="117751" author="craiggwilson" created="Wed, 9 May 2012 17:41:19 +0000"  >&lt;p&gt;This has been merged to master.&lt;/p&gt;</comment>
                            <comment id="117727" author="craiggwilson" created="Wed, 9 May 2012 16:57:54 +0000"  >&lt;p&gt;That is a good idea.  However, an Intersection produces another set, not a boolean value.  Doing this would violate the intention of the Intersect method.  In addition, the compiler wouldn&apos;t like this.  &lt;/p&gt;

&lt;p&gt;One possibility would be to use it in conjunction with the Any method;  (c =&amp;gt; c.List.Intersect(local).Any()) or (c =&amp;gt; local.Intersect(c.List).Any().  We will talk about doing this, but this is a lot of work and would be difficult to document.&lt;/p&gt;</comment>
                            <comment id="117725" author="gautiers" created="Wed, 9 May 2012 16:46:22 +0000"  >&lt;p&gt;Thanks for your reactiveness&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24in&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24in&lt;/a&gt;&lt;br/&gt;
&quot;The target field&apos;s value can also be an array; if so then the document matches if any of the elements of the array&apos;s value matches any of the $in field&apos;s values&quot;&lt;/p&gt;

&lt;p&gt;Maybe this can be implemented in the Intersect linq method. Not really a &quot;Contains&quot; method, but close.&lt;br/&gt;
What do you think ?&lt;/p&gt;</comment>
                            <comment id="116605" author="craiggwilson" created="Sun, 6 May 2012 11:50:45 +0000"  >&lt;p&gt;Thanks for your enthusiasm.  This will be implemented for release 1.5 and will support both the Enumerable.Contains extension method invoked upon a local constant as well as the Contains method of ICollection&amp;lt;T&amp;gt; invoked upon a local constant.  Let me know if there are any more &quot;Contains&quot; methods that should be utilized.&lt;/p&gt;</comment>
                            <comment id="116596" author="gfx00" created="Sun, 6 May 2012 07:50:08 +0000"  >&lt;p&gt;There is an other problem - when you update mongo driver from 1.3 version up to the 1.4 version all your queries with &quot;Contains&quot; must be verified. There would not any compile-time exceptions. Just your query will fail in run-time. That was heppened with my project. I spend some time to check each query because in my DAL are two types of queries: mongo queries and linq-to-object, so i must check where I shoud set &quot;In&quot; and where must be &quot;Contains&quot;.&lt;/p&gt;</comment>
                            <comment id="116573" author="optimiz3" created="Sat, 5 May 2012 18:54:54 +0000"  >&lt;p&gt;+1 for Contains over In; Contains is a standard part of .Net via ICollection&amp;lt;T&amp;gt; whereas In is not.&lt;/p&gt;</comment>
                            <comment id="116363" author="gautiers" created="Fri, 4 May 2012 14:57:35 +0000"  >&lt;p&gt;And to use .In() (like other Linq To MongoDb extension methods), It is necessary to reference the MongoDb Driver dll outside of the database access layer.&lt;br/&gt;
I think supporting collection.Contains() method would allow a better abstraction level by allowing this functionnality to be accessible by code using the standard linq provider interface.&lt;/p&gt;</comment>
                            <comment id="116343" author="rhoffman" created="Fri, 4 May 2012 14:20:32 +0000"  >&lt;p&gt;@Robert - I think the driver should support either way (or, if anything using .Contains() and not .In).  All other LINQ providers that I have used (Objects, SQL, EF, and NHibernate) have done &quot;in&quot; queries with .Contains().  &lt;/p&gt;

&lt;p&gt;I have just converted several NHibernate LINQ queries to MongoDB LINQ queries, and this is one inconsistency.  It is not a big deal to change it to use the .In extension method provided by the driver, however I believe this should be done consistently with other LINQ implementations.&lt;/p&gt;</comment>
                            <comment id="115916" author="gfx00" created="Thu, 3 May 2012 09:55:56 +0000"  >&lt;p&gt;I&apos;m sorry because of my bug is that only that I don&apos;t know how use that library properly.&lt;br/&gt;
I was confussed because all linq providers I worked with do it like &quot;collection.Contains(variable)&quot; so I don&apos;t think that way as you said.&lt;/p&gt;
</comment>
                            <comment id="115912" author="rstam" created="Thu, 3 May 2012 09:46:29 +0000"  >&lt;p&gt;Have you tried:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;Where(x =&amp;gt; x.Id.In(documentFolders))&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Perhaps we should support either way?&lt;/p&gt;</comment>
                            <comment id="115910" author="gfx00" created="Thu, 3 May 2012 09:41:11 +0000"  >&lt;p&gt;FluentMongo supported this&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="531137">CSHARP-2247</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                            <subtask id="530634">CSHARP-2244</subtask>
                    </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|hrh7lj:</customfieldvalue>

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