<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:38:33 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-1056] BsonDocument [DataContract] serialization error</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1056</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I need to serialize a BsonDocument using the DataContractSerializer.&lt;br/&gt;
I have a class Play that has a BsonDocument (see stub below).&lt;/p&gt;

&lt;p&gt;   &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonIgnoreExtraElements&amp;#93;&lt;/span&gt;&lt;br/&gt;
   &lt;span class=&quot;error&quot;&gt;&amp;#91;DataContract(Namespace=&amp;quot;f1&amp;quot;)&amp;#93;&lt;/span&gt;&lt;br/&gt;
   public class Play&lt;br/&gt;
   {&lt;br/&gt;
...&lt;br/&gt;
      &lt;span class=&quot;error&quot;&gt;&amp;#91;DataMember&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;BsonElement&amp;#93;&lt;/span&gt; public BsonDocument  OD   &lt;/p&gt;
{ get; set; }

&lt;p&gt;   }&lt;/p&gt;

&lt;p&gt;Note: the first element in the BsonDocument is a BsonInt32.&lt;/p&gt;

&lt;p&gt;When using the DataContractSerializer, I get the following error:&lt;br/&gt;
Type &apos;MongoDB.Bson.BsonInt32&apos; with data contract name &apos;BsonInt32:&lt;a href=&quot;http://schemas.datacontract.org/2004/07/MongoDB.Bson&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://schemas.datacontract.org/2004/07/MongoDB.Bson&lt;/a&gt;&apos; is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.&lt;/p&gt;
</description>
                <environment></environment>
        <key id="156521">CSHARP-1056</key>
            <summary>BsonDocument [DataContract] serialization error</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="2" iconUrl="https://jira.mongodb.org/images/icons/priorities/critical.svg">Critical - P2</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="-1">Unassigned</assignee>
                                    <reporter username="tonytx">Tony Davis</reporter>
                        <labels>
                    </labels>
                <created>Fri, 5 Sep 2014 03:09:14 +0000</created>
                <updated>Mon, 8 Sep 2014 11:54:30 +0000</updated>
                            <resolved>Mon, 8 Sep 2014 11:54:30 +0000</resolved>
                                    <version>1.9.2</version>
                                                    <component>Serialization</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="713375" author="craiggwilson" created="Mon, 8 Sep 2014 11:54:30 +0000"  >&lt;p&gt;Your use case here is almost exactly the purpose of why &lt;a href=&quot;http://automapper.org/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Automapper&lt;/a&gt; was built.&lt;/p&gt;

&lt;p&gt;I&apos;m going to close this as Won&apos;t Fix as this problem isn&apos;t an area we are focused on. Feel free to leave a comment if you disagree.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                            <comment id="713259" author="tonytx" created="Mon, 8 Sep 2014 04:39:17 +0000"  >&lt;p&gt;I own both sides (client side app and server side) so that is not an issue. It&apos;s looking like I&apos;m going to have to roll my own object layer to handle it and then write the (ORM like code) to map my object layer to mongo and back. It&apos;s been nice so far to not have to do that with all my other objects. A BsonDocument was almost a perfect match for what I needed for the dynamic user defined variables, but it can&apos;t translate to XML or across a WCF border in native form as a &lt;span class=&quot;error&quot;&gt;&amp;#91;DataMember&amp;#93;&lt;/span&gt;. So back to the drawing board for a different solution as it doesn&apos;t appear a BsonDocument is easily fixable to support that.&lt;/p&gt;</comment>
                            <comment id="713026" author="craiggwilson" created="Sat, 6 Sep 2014 16:50:52 +0000"  >&lt;p&gt;Are you forcing your users on the client-side of this stack to take a dependency on MongoDB as well, just to deserialize a BsonDocument?&lt;/p&gt;</comment>
                            <comment id="712959" author="tonytx" created="Sat, 6 Sep 2014 02:13:54 +0000"  >&lt;p&gt;I allow the user to add additional data variables dynamically at run-time in order to customize the application to their needs. Using a BsonDocument handles this very nicely - well until I need to send it through a WCF interface or export to XML. I tried out exporting a Dictionary&amp;lt;string, object&amp;gt;. It is very expensive via XML because it must add all the type information for each element in a very verbose way. I need something that works well on both sides: (1) mongo database storage and (2) WFC and for importing/exporting to/from XML. This is needed when working in a Windows stack.&lt;/p&gt;</comment>
                            <comment id="712327" author="craiggwilson" created="Fri, 5 Sep 2014 13:37:00 +0000"  >&lt;p&gt;Hi Tony,&lt;/p&gt;

&lt;p&gt;Sorry you are having trouble. BsonDocument and it&apos;s cohorts (BsonInt32, BsonString, etc...) don&apos;t play well with the DataContractSerializer. I&apos;d suggest you use something like a Dictionary&amp;lt;string, object&amp;gt; instead.  Alternatively, instead of having a catch-all type of property like this, go ahead and define your structure in a class. I know this can&apos;t always be done.  Perhaps you could provide the reason you are using a BsonDocument here?&lt;/p&gt;

&lt;p&gt;Craig&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|hs1ylb:</customfieldvalue>

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