<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:46 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-420] Issue when try to access Collection.AsQueryable&lt;T&gt; when no query is specified</title>
                <link>https://jira.mongodb.org/browse/CSHARP-420</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;This code isn&apos;t working.  The&lt;br/&gt;
Employee class is defined as follows for the code example:&lt;/p&gt;

&lt;p&gt;   public class Employee&lt;br/&gt;
   {&lt;br/&gt;
       public ObjectId id &lt;/p&gt;
{ get; set; }&lt;br/&gt;
&lt;br/&gt;
       &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonElement(&amp;quot;fn&amp;quot;)&amp;#93;&lt;/span&gt;&lt;br/&gt;
       public string FirstName { get; set; }
&lt;p&gt;   }&lt;/p&gt;

&lt;p&gt;If I do the following, I get an exception on the ToList() line:&lt;/p&gt;

&lt;p&gt;           var connectionString = &quot;mongodb://localhost/sportsstore?&lt;br/&gt;
slaveOk=true&quot;;&lt;br/&gt;
           var databaseName =&lt;br/&gt;
MongoUrl.Create(connectionString).DatabaseName;&lt;br/&gt;
           var server = MongoServer.Create(connectionString);&lt;br/&gt;
           var db = server.GetDatabase(databaseName);&lt;/p&gt;

&lt;p&gt;           var eCollection = db.GetCollection&amp;lt;Employee&amp;gt;(&quot;employees&quot;);&lt;br/&gt;
           eCollection.Drop();&lt;br/&gt;
           eCollection.Insert(new Employee &lt;/p&gt;
{FirstName = &quot;Nick&quot;}
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;           var employees =&lt;br/&gt;
eCollection.AsQueryable&amp;lt;Employee&amp;gt;().ToList();&lt;/p&gt;

&lt;p&gt;The exception I get is this:&lt;/p&gt;

&lt;p&gt;System.ArgumentOutOfRangeException was unhandled&lt;br/&gt;
 Message=Specified argument was out of the range of valid values.&lt;br/&gt;
Parameter name: Unable to find root IQueryable&lt;br/&gt;
 Source=MongoDB.Driver&lt;br/&gt;
 ParamName=Unable to find root IQueryable&lt;br/&gt;
 StackTrace:&lt;br/&gt;
      at&lt;br/&gt;
MongoDB.Driver.Linq.MongoQueryTranslator.GetDocumentType(Expression&lt;br/&gt;
expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq&lt;br/&gt;
\Translators\MongoQueryTranslator.cs:line 80&lt;br/&gt;
      at&lt;br/&gt;
MongoDB.Driver.Linq.MongoQueryTranslator.Translate(MongoQueryProvider&lt;br/&gt;
provider, Expression expression) in C:\work\10gen\mongodb\mongo-csharp-&lt;br/&gt;
driver\Driver\Linq\Translators\MongoQueryTranslator.cs:line 50&lt;br/&gt;
      at MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression&lt;br/&gt;
expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq&lt;br/&gt;
\MongoQueryProvider.cs:line 146&lt;br/&gt;
      at MongoDB.Driver.Linq.MongoQueryable`1.GetEnumerator() in C:&lt;br/&gt;
\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq&lt;br/&gt;
\MongoQueryable.cs:line 81&lt;br/&gt;
      at System.Collections.Generic.List`1..ctor(IEnumerable`1&lt;br/&gt;
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 MongoQueryTester.Program.Main(String[] args) in c:\users&lt;br/&gt;
\ncipollina\documents\visual studio 2010\Projects\MongoQueryTester&lt;br/&gt;
\MongoQueryTester\Program.cs:line 27&lt;br/&gt;
      at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,&lt;br/&gt;
String[] args)&lt;br/&gt;
      at System.AppDomain.ExecuteAssembly(String assemblyFile,&lt;br/&gt;
Evidence assemblySecurity, String[] args)&lt;br/&gt;
      at&lt;br/&gt;
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()&lt;br/&gt;
      at System.Threading.ThreadHelper.ThreadStart_Context(Object&lt;br/&gt;
state)&lt;br/&gt;
      at System.Threading.ExecutionContext.Run(ExecutionContext&lt;br/&gt;
executionContext, ContextCallback callback, Object state, Boolean&lt;br/&gt;
ignoreSyncCtx)&lt;br/&gt;
      at System.Threading.ExecutionContext.Run(ExecutionContext&lt;br/&gt;
executionContext, ContextCallback callback, Object state)&lt;br/&gt;
      at System.Threading.ThreadHelper.ThreadStart()&lt;br/&gt;
 InnerException:&lt;/p&gt;


&lt;p&gt;Now if I change the line that has ToList() to this it works:&lt;/p&gt;

&lt;p&gt;var employees = eCollection.FindAll().AsQueryable().ToList();&lt;/p&gt;</description>
                <environment>Window 7 - 64 Bit, Visual Studio 2010</environment>
        <key id="35054">CSHARP-420</key>
            <summary>Issue when try to access Collection.AsQueryable&lt;T&gt; when no query is specified</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="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="ncipollina">Nick Cipollina</reporter>
                        <labels>
                            <label>linq,query</label>
                    </labels>
                <created>Fri, 30 Mar 2012 00:20:21 +0000</created>
                <updated>Thu, 2 Apr 2015 18:28:26 +0000</updated>
                            <resolved>Fri, 30 Mar 2012 04:38:47 +0000</resolved>
                                    <version>1.4</version>
                                    <fixVersion>1.4.1</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="35044">CSHARP-419</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|hrh7u7:</customfieldvalue>

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