<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:05 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-197] Proxy attribute on properties?</title>
                <link>https://jira.mongodb.org/browse/CSHARP-197</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;It would be great if I could mark a class with an attribute so that the C# driver knows it needs to load/fetch (a join) additional documents without having to hand code this each time:&lt;/p&gt;

&lt;p&gt;&amp;#8211;&lt;/p&gt;

&lt;p&gt;class Order&lt;br/&gt;
{&lt;br/&gt;
	&lt;span class=&quot;error&quot;&gt;&amp;#91;BsonReference(&amp;quot;db.users&amp;quot;, &amp;quot;_id&amp;quot;, &amp;quot;UserId)&amp;#93;&lt;/span&gt;&lt;br/&gt;
	public User User &lt;/p&gt;
{get;set;}&lt;br/&gt;
	...&lt;br/&gt;
}&lt;br/&gt;
&lt;br/&gt;
- Or lazy loading -&lt;br/&gt;
&lt;br/&gt;
class Order&lt;br/&gt;
{&lt;br/&gt;
	&lt;span class=&quot;error&quot;&gt;&amp;#91;BsonReference(&amp;quot;db.users&amp;quot;, &amp;quot;_id&amp;quot;, &amp;quot;UserId)&amp;#93;&lt;/span&gt;&lt;br/&gt;
	public Reference&amp;lt;User&amp;gt; User {get;set;}
&lt;p&gt;	...&lt;br/&gt;
}&lt;br/&gt;
&amp;#8211;&lt;/p&gt;

&lt;p&gt;In both examples, I indicate that this Order class (that the driver knows about due to mappings) has a User property that I would like to be loaded each time an Order is loaded as well. Let the driver load this on my behalf.&lt;/p&gt;

&lt;p&gt;The first version would always load the property, the second would lazy load for me - accessing the order.User property would lazy load the proxy in the background (the driver would fetch the instance for me).&lt;/p&gt;

&lt;p&gt;I&apos;d like to avoid having to use a &apos;DBRef&apos; in this case because the relationship is obvious (its always going to be a User I want loaded, found in the db.users collection).&lt;/p&gt;

&lt;p&gt;I also want to avoid using the &apos;FollowReference&apos; syntax because it means I can&apos;t just use order.User I need to put a UserId on the Order instance (which is a bit unclean) and would rather be able to access the object directly (while being aware its going to cost in terms of performance).&lt;/p&gt;

&lt;p&gt;Thoughts?&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Andrew&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="15861">CSHARP-197</key>
            <summary>Proxy attribute on properties?</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="craig.wilson@mongodb.com">Craig Wilson</assignee>
                                    <reporter username="plasma">Andrew Armstrong</reporter>
                        <labels>
                            <label>question</label>
                    </labels>
                <created>Sun, 10 Apr 2011 06:22:41 +0000</created>
                <updated>Fri, 5 Apr 2019 13:59:30 +0000</updated>
                            <resolved>Fri, 4 May 2012 17:53:51 +0000</resolved>
                                    <version>1.0</version>
                                                    <component>Feature Request</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="116407" author="craiggwilson" created="Fri, 4 May 2012 17:53:32 +0000"  >&lt;p&gt;Andrew,&lt;br/&gt;
  We have discussed this request and determined that supporting proxies and lazy loading is beyond the scope of the driver.  The use case for this feature would get used so rarely that it is not worth the complexity of implementation.  While it is a little inconvenient to &quot;dereference&quot; manuallly, it is supported and available.  &lt;/p&gt;

&lt;p&gt;  However, if you truly want this feature, you can implement a custom IBsonSerializer that generates the necessary code yourself using Castle&apos;s DynamicProxy, LinFu, or another proxy generating library.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="17613">CSHARP-232</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </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|hrh94n:</customfieldvalue>

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