<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37:02 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-505] System.MissingMethodException on enumerating IQueryable&lt;Abstract&gt;</title>
                <link>https://jira.mongodb.org/browse/CSHARP-505</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Consider this example, where Concrete represents a collection and happens to derive from Abstract, which is an abstract base class.&lt;/p&gt;

&lt;p&gt;IQueryable&amp;lt;Concrete&amp;gt; concretes = collection.AsQueryable();&lt;br/&gt;
IQueryable&amp;lt;Abstract&amp;gt; abstracts = concretes;&lt;/p&gt;

&lt;p&gt;var queryResults = abstracts.Where(...).ToList(); // results in MissingMethodException&lt;/p&gt;

&lt;p&gt;System.MissingMethodException: Constructor on type &apos;MongoDB.Driver.Linq.Projector2[[&lt;span class=&quot;error&quot;&gt;&amp;#91;MongoDB.Bson.ObjectId, MongoDB.Bson, Version=1.5.0.26036, Culture=neutral, PublicKeyToken=f686731cfb9cc103&amp;#93;&lt;/span&gt;]&apos; not found. at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at MongoDB.Driver.Linq.SelectQuery.Execute() at MongoDB.Driver.Linq.MongoQueryable1.GetEnumerator()&lt;/p&gt;

&lt;p&gt;Note &amp;#8211; this used to work perfectly in Fluent mongo.&lt;/p&gt;</description>
                <environment></environment>
        <key id="41882">CSHARP-505</key>
            <summary>System.MissingMethodException on enumerating IQueryable&lt;Abstract&gt;</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="zaidmasud">Zaid Masud</reporter>
                        <labels>
                            <label>linq</label>
                            <label>linq,query</label>
                    </labels>
                <created>Wed, 20 Jun 2012 14:56:15 +0000</created>
                <updated>Tue, 28 Apr 2015 19:42:44 +0000</updated>
                            <resolved>Tue, 28 Apr 2015 19:42:30 +0000</resolved>
                                    <version>1.4.2</version>
                    <version>1.5</version>
                                    <fixVersion>2.1</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="900171" author="craiggwilson" created="Tue, 28 Apr 2015 19:42:30 +0000"  >&lt;p&gt;This was fixed as part of &lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-601&quot; title=&quot;Linq to Aggregation Framework&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-601&quot;&gt;&lt;del&gt;CSHARP-601&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="137504" author="craiggwilson" created="Thu, 28 Jun 2012 13:41:56 +0000"  >&lt;p&gt;This already works (or will work with the release of 1.5).  You can see the tests here: &lt;a href=&quot;https://github.com/mongodb/mongo-csharp-driver/blob/master/DriverUnitTests/Linq/SelectOfTypeHierarchicalTests.cs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-csharp-driver/blob/master/DriverUnitTests/Linq/SelectOfTypeHierarchicalTests.cs&lt;/a&gt;.  In addition, as is also indicated in the tests, you can use the OfType&amp;lt;T&amp;gt; operator.&lt;/p&gt;

&lt;p&gt;I&apos;m going to mark this feature request for 2.0 as there is already a decent workaround for this issue.&lt;/p&gt;</comment>
                            <comment id="134841" author="zaidmasud" created="Wed, 20 Jun 2012 16:54:02 +0000"  >&lt;p&gt;Good point, are there any plans for supporting type discriminators with LINQ? For example, rather than the following:&lt;/p&gt;

&lt;p&gt;var query = Query.EQ(&quot;_t&quot;, &quot;Cat&quot;);&lt;/p&gt;

&lt;p&gt;I would love to write:&lt;/p&gt;

&lt;p&gt;collection.AsQueryable().Where(d =&amp;gt; d is Cat);&lt;/p&gt;

&lt;p&gt;And I&apos;m sure much could be made of the Cast&amp;lt;&amp;gt; LINQ extension method as well.&lt;/p&gt;</comment>
                            <comment id="134832" author="craiggwilson" created="Wed, 20 Jun 2012 16:40:52 +0000"  >&lt;p&gt;I agree with your analysis of what you are wanting.  However, we do support type discriminators so descendant classes of Abstract could exist in the same collection.  This is actually going to take some where I think.&lt;/p&gt;</comment>
                            <comment id="134799" author="zaidmasud" created="Wed, 20 Jun 2012 15:45:55 +0000"  >&lt;p&gt;It should return only concretes typed as Abstract.&lt;/p&gt;

&lt;p&gt;I don&apos;t see how it would be possible to get back any type that descends from Abstract, as each type would be represented as a separate collection?&lt;/p&gt;

&lt;p&gt;I would like to see an exception if the IQueryable&amp;lt;Abstract&amp;gt; contains multiple types in it, although I cannot think of a possible way that such an IQueryable could be constructed.&lt;/p&gt;</comment>
                            <comment id="134795" author="craiggwilson" created="Wed, 20 Jun 2012 15:38:16 +0000"  >&lt;p&gt;In your mind, what should this be doing?  When you finally execute abstracts.ToList(), should you only get back concretes or would you get back any type that descends from Abstract?&lt;/p&gt;</comment>
                    </comments>
                    <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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>CSHARP-935</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hs7utb:</customfieldvalue>

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