<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Entity instances are not directly serializable</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Entity instances are not directly serializable</description>
  <pubDate>Tue, 28 Apr 2026 09:40:10 -700</pubDate>
  <lastBuildDate>Tue, 28 Apr 2009 15:32:21 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1238</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Entity instances are not directly serializable : That&amp;#039;s right. They can&amp;#039;t...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1238&amp;PID=4462#4462</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=482" rel="nofollow">WardBell</a><br /><strong>Subject:</strong> 1238<br /><strong>Posted:</strong> 28-Apr-2009 at 3:32pm<br /><br />That's right. They can't be for a number of really good reasons including<OL><LI>Serializer would follow down the navigation properties which at minimum means serializing enormous amounts of unrequested data and almost certainly leads to circular references with disasterous results.</LI><LI>Many-to-many relationships don't serialize</LI><LI>Serializer would invoke your custom properties unless you blocked them (leaving aside opt-in DataContract)</LI><LI>Property invocation might execute code inside the properties (we could block execution of injection code ... but it's just another complication).</LI></OL><P>So how do we do it? We don't serialize the entities. We serialize the persistent data <EM><strong>inside</strong></EM> your entities. We do this for single entities and collections of entities. Our EntityCacheState provides this same mechanism to you.</P><DIV>We know where the data really are. We pull them out of the entities, push them into surrogate class instances, and THAT is what travels over the wire.</DIV><DIV>&nbsp;</DIV><DIV>But you noticed that we have the &#091;DataContract&#093; attribute on our generated entity classes. Does that mean that they really are serializable?</DIV><DIV>&nbsp;</DIV><DIV>Ah ... did you notice that there are no &#091;DataMember&#093; attributes on any of the members?&nbsp;&nbsp;DataContract serialization is opt-in. No member is serialized unless it is marked with &#091;DataMember&#093;. Traditional serialization (such as when marking a class &#091;Serializable&#093;) is opt-out; every property goes unless explictly excluded from serialization.</DIV><DIV>&nbsp;</DIV><DIV>So if you tried to use DataContract serialization on our entities, none of whose members are marked with &#091;DataMember&#093;,&nbsp;you'd get a big, fat nothing.</DIV><DIV>&nbsp;</DIV><DIV>That's intentional ... and necessary! By marking the class with &#091;DataContract&#093;, we <strong><EM>prevent accidental .NET serialization</EM></strong> - which would lead to all of the complications mentioned at the beginning of the post ... as we've learned the hard way.</DIV>]]>
   </description>
   <pubDate>Tue, 28 Apr 2009 15:32:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1238&amp;PID=4462#4462</guid>
  </item> 
 </channel>
</rss>