<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Customizing Serialization of Entities in the ADO.NET Data Services Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx</link><description>This post is inspired by this forum thread : Data services client -- exception on saveChanges Problem Statement I have added some custom proeprties to the Entity Types Generated by DataSvcUtil.exe /Add Service Reference / Hand Coded , these properties</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Attention! Phani on Deck!</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx#9203031</link><pubDate>Fri, 12 Dec 2008 21:23:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9203031</guid><dc:creator>Man vs Code</dc:creator><description>&lt;p&gt;One of the most common feature requests we hear for Astoria is the ability to mark properties on an entity&lt;/p&gt;
</description></item><item><title>re: Customizing Serialization of Entities in the ADO.NET Data Services Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx#9515480</link><pubDate>Sat, 28 Mar 2009 06:02:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9515480</guid><dc:creator>Keoz</dc:creator><description>&lt;p&gt;You know this completes the circle since whe can partialize a data entity to implemente INotifyPropertyChanged and we can mark an attribute to dont be part of the context we now really can customize and use a data entity in business layer so we dont need extra classes to achieve this, thats one of the many things i love data services, great post! thank you!!&lt;/p&gt;</description></item><item><title>re: Customizing Serialization of Entities in the ADO.NET Data Services Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx#9563461</link><pubDate>Thu, 23 Apr 2009 02:02:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9563461</guid><dc:creator>Charles</dc:creator><description>&lt;p&gt;This is a very cool idea, but I'm curious if it can be used on a field in an ADO.NET entity model? &amp;nbsp;If so, how would I set a field there to have the DoNotSerialize property?&lt;/p&gt;</description></item><item><title>re: Customizing Serialization of Entities in the ADO.NET Data Services Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx#9563726</link><pubDate>Thu, 23 Apr 2009 04:24:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9563726</guid><dc:creator>PhaniRajuYN</dc:creator><description>&lt;p&gt;Hi Charles,&lt;/p&gt;
&lt;p&gt;This property is client-side only. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;By design , the server does not expose any events for us to hook in and change the markup . &lt;/p&gt;
&lt;p&gt;Which scenario are you trying to solve with this ?&lt;/p&gt;
&lt;p&gt;-Phani &lt;/p&gt;
</description></item><item><title>re: Customizing Serialization of Entities in the ADO.NET Data Services Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx#9607586</link><pubDate>Tue, 12 May 2009 19:12:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9607586</guid><dc:creator>John Allen</dc:creator><description>&lt;p&gt;I may be missing something but I'm trying to use this in a Silverlight project and my derived class that inherits from DataServiceContext is auto generated for my Service Reference. &amp;nbsp;If I update the code that defines my Service Reference to inherit from my new custom class it is simply blown away the next time I refresh the service. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;What am I missing?&lt;/p&gt;</description></item><item><title>re: Customizing Serialization of Entities in the ADO.NET Data Services Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx#9634630</link><pubDate>Fri, 22 May 2009 05:29:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9634630</guid><dc:creator>PhaniRajuYN</dc:creator><description>&lt;p&gt;Hi John,&lt;/p&gt;
&lt;p&gt; You are right . I wanted to update this blog entry to use a partial class instead of an inherited class for a long time .&lt;/p&gt;
&lt;p&gt; Using a partial class preserves this code in another code file and doesnt get affected if you re-generate the client proxy classes.&lt;/p&gt;
&lt;p&gt;-Phani &lt;/p&gt;
</description></item><item><title>re: Customizing Serialization of Entities in the ADO.NET Data Services Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx#9834410</link><pubDate>Wed, 15 Jul 2009 19:19:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9834410</guid><dc:creator>Pedro Garces</dc:creator><description>&lt;p&gt;I was having the same issue with ADO.NET Service generated classes that we wanted to extend (since they are partial classes).&lt;/p&gt;
&lt;p&gt;I tried several techniques to do the serialization in order to exclude the newly created (extended) properties to the ADO.NET generated classes, since ADO.NET detects the newly created properties; which causes an exception specifying the NONE existing properties.&lt;/p&gt;
&lt;p&gt;Some didn't work, other were very tricky. So I found this solution much cleaner and practical.&lt;/p&gt;
&lt;p&gt;The only problem I found was the LINQ code to access the extended properties to remove them from the ATOM Payload, doesn't work anymore. The methods to process the Lambda expression don't exist or the version I have in silverlight is different. So I fix it this way to eliminate a propertyname (string):&lt;/p&gt;
&lt;p&gt;XName xNameProperty = XName.Get(propertyName, rootElement.GetNamespaceOfPrefix(&amp;quot;d&amp;quot;).NamespaceName);&lt;/p&gt;
&lt;p&gt;//Get descendants for xNameProperty object within ALL xElements&lt;/p&gt;
&lt;p&gt;IEnumerable&amp;lt;XElement&amp;gt; PropertyElements = rootElement.Descendants(xNameProperty);&lt;/p&gt;
&lt;p&gt;//Initialize variable&lt;/p&gt;
&lt;p&gt;XElement elementxHasProperty = null;&lt;/p&gt;
&lt;p&gt;//Find xElement for the searched propertyName&lt;/p&gt;
&lt;p&gt;foreach (XElement element in PropertyElements)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Verify if it is the property looked for&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (element.Name.LocalName == xNameProperty.LocalName)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elementxHasProperty = element;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;//Verify if the propertyName was found to remove the property from being sent to ADO.NET Services&lt;/p&gt;
&lt;p&gt;if (elementxHasProperty != null)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elementxHasProperty.Remove();&lt;/p&gt;
&lt;p&gt;Thank you so much for your guidance&lt;/p&gt;</description></item></channel></rss>