<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37:30 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-669] Retrieve Many-to-Many Object collection vai ObjectId Array</title>
                <link>https://jira.mongodb.org/browse/CSHARP-669</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;In order to do the many-to-many between tmpCategory &amp;amp; tmpProduct, I use a ObjectId list to store the which category that a product related to. When I get the &quot;tmpProduct&quot; object back from C# driver and would like to use &quot;tmpProduct.Category_Ids&quot; to retrieve the tmpCategory collection back utilize below method:&lt;/p&gt;

&lt;p&gt;var categories = mongoCollection_Category.FindAs&amp;lt;tmpCategory&amp;gt;(Query.In(&quot;_id&quot;,product.Category_Ids));&lt;/p&gt;

&lt;p&gt;=&amp;gt; C# complains that product.Category_Ids is not IEnumerable&amp;lt;BsonValue&amp;gt;??&lt;br/&gt;
=&amp;gt; However, the LINQ statement would work like below:&lt;/p&gt;

&lt;p&gt;var categories2 = (from obj in mongoCollection_Category.AsQueryable&amp;lt;tmpCategory&amp;gt;()&lt;br/&gt;
                        where obj.Id.In(product.Category_Ids)&lt;br/&gt;
                        select obj).ToList&amp;lt;tmpCategory&amp;gt;();&lt;/p&gt;


&lt;p&gt;public class tmpCategory&lt;br/&gt;
{&lt;br/&gt;
  public ObjectId Id &lt;/p&gt;
{ get; private set; }&lt;br/&gt;
  public string Title { get; set; }        &lt;br/&gt;
}&lt;br/&gt;
&lt;br/&gt;
public class tmpProduct&lt;br/&gt;
{&lt;br/&gt;
  private IList&amp;lt;ObjectId&amp;gt; _category_ids = new List&amp;lt;ObjectId&amp;gt;();&lt;br/&gt;
&lt;br/&gt;
  public ObjectId Id { get; private set; }
&lt;p&gt;  public string Name &lt;/p&gt;
{ get; set; }
&lt;p&gt;  public IList&amp;lt;ObjectId&amp;gt; Category_Ids&lt;br/&gt;
  {&lt;br/&gt;
    get &lt;/p&gt;
{ return _category_ids; }
&lt;p&gt;    set &lt;/p&gt;
{ _category_ids = value; }
&lt;p&gt;  }&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Would it be easier to have C# driver to add below methods?&lt;/p&gt;

&lt;p&gt;1.Query.In(&quot;_id&quot;, IEnumerable&amp;lt;ObjectId&amp;gt;)&lt;br/&gt;
2.MongoCollection.FindAllByIdsAs(IEnumerable&amp;lt;ObjectId&amp;gt;)&lt;/p&gt;</description>
                <environment></environment>
        <key id="63212">CSHARP-669</key>
            <summary>Retrieve Many-to-Many Object collection vai ObjectId Array</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="-1">Unassigned</assignee>
                                    <reporter username="erhwenkuo">ErhWenKuo</reporter>
                        <labels>
                    </labels>
                <created>Thu, 24 Jan 2013 23:05:12 +0000</created>
                <updated>Thu, 20 Mar 2014 14:36:23 +0000</updated>
                            <resolved>Wed, 13 Feb 2013 14:26:36 +0000</resolved>
                                    <version>1.7</version>
                                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="249133" author="craiggwilson" created="Thu, 24 Jan 2013 23:29:20 +0000"  >&lt;p&gt;You can do this in 1 of 3 ways.  As you have statement that Linq works, any reason not to use it?&lt;/p&gt;

&lt;p&gt;2) Your version casting the ObjectId into a BsonValue.&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 categoryIds = product.Category_Ids.Select(x =&amp;gt; (BsonValue)x);&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;var categories = mongoCollection_Category.FindAs&amp;lt;tmpCategory&amp;gt;(Query.In(&quot;_id&quot;, categoryIds));&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;3) Using tje Typed Query Builder.  Query&amp;lt;T&amp;gt;.In&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;var categories = mongoCollection_Category.FindAs&amp;lt;tmpCategory&amp;gt;(Query&amp;lt;tmpCategory&amp;gt;.In(x =&amp;gt; x.Id, product.Category_Ids));&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrlssv:</customfieldvalue>

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