<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:49:52 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-4957] IMongoCollection.AsQueryable().Select() fails for array type (regression)</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4957</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;&#160;&lt;br/&gt;
&lt;tt&gt;// IMongoCollection&amp;lt;TestClass&amp;gt; collection;&lt;/tt&gt;&lt;tt&gt;collection.AsQueryable().Select(t =&amp;gt; (IEnumerable&amp;lt;&lt;font color=&quot;#0000ff&quot;&gt;int&lt;/font&gt;&amp;gt;) &lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt;[] { t.Integer }).ToArray()&lt;/tt&gt;&lt;br/&gt;
throws the following exception on 2.23.1:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;MongoDB.Driver.Linq.ExpressionNotSupportedException: Expression not supported: t =&amp;gt; new [] {t.Integer} because lambda body type is not convertible to lambda return type.&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToAggregationExpressionTranslators.ExpressionToAggregationExpressionTranslator.TranslateLambdaBody(TranslationContext context, LambdaExpression lambdaExpression, IBsonSerializer parameterSerializer, Boolean asRoot)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToPipelineTranslators.SelectMethodToPipelineTranslator.Translate(TranslationContext context, MethodCallExpression expression)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToPipelineTranslators.ExpressionToPipelineTranslator.Translate(TranslationContext context, Expression expression)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators.ExpressionToExecutableQueryTranslator.Translate&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument,TOutput&amp;#93;&lt;/span&gt;(MongoQueryProvider`1 provider, Expression expression)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.MongoQuery`2.Execute()&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.MongoQuery`2.GetEnumerator()&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at System.Collections.Generic.EnumerableHelpers.ToArray&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at System.Linq.Enumerable.ToArray&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;/tt&gt;&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.23.1&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;AdditionalBackground&quot;&gt;&lt;/a&gt;Additional Background&lt;/h4&gt;

&lt;p&gt;This works on 2.18.0. From 2.19.0 it fails, though with a different (worse) exception message:{{{}&lt;br/&gt;
{}}}&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;System.InvalidCastException: Unable to cast object of type &apos;MongoDB.Driver.Linq.Linq3Implementation.Serializers.WrappedValueSerializer`1[System.Collections.Generic.IEnumerable`1&lt;span class=&quot;error&quot;&gt;&amp;#91;System.Int32&amp;#93;&lt;/span&gt;]&apos; to type &apos;MongoDB.Bson.Serialization.IBsonSerializer`1[System.Int32[]]&apos;.&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators.ExecutableQuery`3.CreateCollectionPipelineDefinition()&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators.ExecutableQuery`3.Execute(IClientSessionHandle session, CancellationToken cancellationToken)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.MongoQuery`2.Execute()&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at MongoDB.Driver.Linq.Linq3Implementation.MongoQuery`2.GetEnumerator()&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at System.Collections.Generic.EnumerableHelpers.ToArray&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; &#160;at System.Linq.Enumerable.ToArray&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;A workaround is to cast the lambda result to IEnumerable&amp;lt;T&amp;gt;:&lt;/p&gt;


&lt;p&gt;&lt;tt&gt;.&lt;font color=&quot;#74531f&quot;&gt;AsQueryable&lt;/font&gt;().&lt;font color=&quot;#74531f&quot;&gt;Select&lt;/font&gt;(&lt;font color=&quot;#1f377f&quot;&gt;t &lt;/font&gt;=&amp;gt; (&lt;font color=&quot;#2b91af&quot;&gt;IEnumerable&lt;/font&gt;&amp;lt;&lt;font color=&quot;#0000ff&quot;&gt;int&lt;/font&gt;&amp;gt;) &lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt;[] { &lt;font color=&quot;#1f377f&quot;&gt;t&lt;/font&gt;.Integer }).&lt;font color=&quot;#74531f&quot;&gt;ToArray&lt;/font&gt;();&lt;/tt&gt;&lt;br/&gt;
&#160;&lt;br/&gt;
This is a bit of a &quot;gotcha&quot; though, as it&apos;s hard to find all places in our code that may be affected by it (and of course the results then have to be cast back to array somewhere if the caller expects that).&lt;/p&gt;</description>
                <environment></environment>
        <key id="2568307">CSHARP-4957</key>
            <summary>IMongoCollection.AsQueryable().Select() fails for array type (regression)</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="11262" iconUrl="https://jira.mongodb.org/images/icons/statuses/generic.png" description="">Investigating</status>
                    <statusCategory id="4" key="indeterminate" colorName="inprogress"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="evgeny+mongodb@loop54.com">Evgeny Morozov</reporter>
                        <labels>
                    </labels>
                <created>Tue, 6 Feb 2024 14:09:50 +0000</created>
                <updated>Wed, 7 Feb 2024 17:12:36 +0000</updated>
                                            <version>2.19.0</version>
                    <version>2.23.1</version>
                                                    <component>LINQ3</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="6075751" author="rstam" created="Wed, 7 Feb 2024 17:12:36 +0000"  >&lt;p&gt;Now that I have the parenthesis in the same place that you do I also get the same exception that you got.&lt;/p&gt;

&lt;p&gt;I will investigate further.&lt;/p&gt;

&lt;p&gt;Thanks for noticing that my test was different than your code.&lt;/p&gt;</comment>
                            <comment id="6075634" author="rstam" created="Wed, 7 Feb 2024 16:48:01 +0000"  >&lt;p&gt;Sorry I read your code wrong. I will change the test and see if I get the same error you do.&lt;/p&gt;</comment>
                            <comment id="6074238" author="JIRAUSER1277113" created="Wed, 7 Feb 2024 09:02:22 +0000"  >&lt;p&gt;Also,&lt;/p&gt;
&lt;div class=&apos;table-wrap&apos;&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;font color=&quot;#000000&quot;&gt;var queryable = collection.AsQueryable()&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&lt;font color=&quot;#000000&quot;&gt;&#160; &#160; .Select(x =&amp;gt; (&lt;/font&gt;&lt;font color=&quot;#006699&quot;&gt;new&lt;/font&gt;&lt;font color=&quot;#000000&quot;&gt;[] { x.Integer }).ToArray()); &lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;


&lt;p&gt;is not the same as my code. The brackets are placed differently, giving it a different meaning.&lt;/p&gt;</comment>
                            <comment id="6074220" author="JIRAUSER1277113" created="Wed, 7 Feb 2024 08:51:32 +0000"  >&lt;p&gt;Hi Robert, have you tested it on either of the two versions in &quot;Affects Version/s&quot;?&lt;/p&gt;</comment>
                            <comment id="6072086" author="rstam" created="Tue, 6 Feb 2024 16:53:55 +0000"  >&lt;p&gt;I am unable to reproduce this.&lt;/p&gt;

&lt;p&gt;I used the following test statement:&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;&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;var queryable = collection.AsQueryable()&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;&#160; &#160; .Select(x =&amp;gt; (&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;new&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;[] { x.Integer }).ToArray());&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;When using LINQ2 this throws a `NotSupportedException`.&lt;/p&gt;

&lt;p&gt;When using LINQ3 this translates to the following aggregation pipeline:&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;{ $project : { _v : [&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&apos;$Integer&apos;&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;], _id : &lt;/span&gt;&lt;span style=&quot;color: #009900; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;0&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; } } &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;I tested against the latest version of the driver source code on the master branch. Let me know if this is only failing in a particular version of the driver.&lt;/p&gt;

&lt;p&gt;Calling ToArray on something that is already an array is redundant, but it is legal and should work.&lt;/p&gt;</comment>
                            <comment id="6071282" author="JIRAUSER1277113" created="Tue, 6 Feb 2024 14:12:45 +0000"  >&lt;p&gt;Sorry, the code in &quot;Summary&quot; is with the workaround, and it seems that I cannot edit it. The code that fails is&lt;br/&gt;
&#160;&lt;br/&gt;
&lt;font color=&quot;#007f00&quot;&gt;// IMongoCollection&amp;lt;TestClass&amp;gt; collection;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;var &lt;/font&gt;&lt;font color=&quot;#a9a9a9&quot;&gt;thisFails &lt;/font&gt;= &lt;font color=&quot;#1f377f&quot;&gt;collection&lt;/font&gt;.&lt;font color=&quot;#74531f&quot;&gt;AsQueryable&lt;/font&gt;().&lt;font color=&quot;#74531f&quot;&gt;Select&lt;/font&gt;(&lt;font color=&quot;#1f377f&quot;&gt;t &lt;/font&gt;=&amp;gt; &lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt;[] { &lt;font color=&quot;#1f377f&quot;&gt;t&lt;/font&gt;.Integer }).&lt;font color=&quot;#74531f&quot;&gt;ToArray&lt;/font&gt;();&lt;br/&gt;
&#160;&lt;/p&gt;</comment>
                            <comment id="6071276" author="dbeng-pm-bot" created="Tue, 6 Feb 2024 14:09:54 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=evgeny%2Bmongodb%40loop54.com&quot; class=&quot;user-hover&quot; rel=&quot;evgeny+mongodb@loop54.com&quot;&gt;evgeny+mongodb@loop54.com&lt;/a&gt;, thank you for reporting this issue! The team will look into it and get back to you soon. &lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                    <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="26434"><![CDATA[Dotnet Drivers]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <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|i2tot8:</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>