<?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>With Great Power comes Great Response.write("Ability") : Documentation</title><link>http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx</link><description>Tags: Documentation</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>ADO.NET Data Services : Efficient Error Handling across Application Tiers</title><link>http://blogs.msdn.com/phaniraj/archive/2009/11/14/ado-net-data-services-efficient-error-handling-across-application-tiers.aspx</link><pubDate>Sat, 14 Nov 2009 04:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9922386</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9922386.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9922386</wfw:commentRss><description>&lt;p&gt;While developing an application that spans multiple tiers , it is important that you be able to flow error information through the tiers without losing    &lt;br /&gt;any context or details in the tiers. With ADO.NET Data Services , we have an error contract which guarantees that all errors thrown from the Data Service ,     &lt;br /&gt;wrapped inside a &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.services.dataserviceexception.aspx"&gt;DataServiceException&lt;/a&gt; , will be represented in a standard way on the wire when we send the error down to the client.     &lt;br /&gt;    &lt;br /&gt;For example , consider the Query Interceptor shown below . &lt;/p&gt;  &lt;pre class="csharpcode"&gt;[QueryInterceptor(&lt;span class="str"&gt;&amp;quot;Customers&amp;quot;&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; Expression&amp;lt;Func&amp;lt;Customers, &lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt;&amp;gt; OnQueryCustomers()
{
        &lt;span class="kwrd"&gt;string&lt;/span&gt; loggedInUser = HttpContext.Current.User.Identity.Name;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (UserHasAccessToSet(&lt;span class="str"&gt;&amp;quot;Customers&amp;quot;&lt;/span&gt;, loggedInUser))
        {
            &lt;span class="rem"&gt;//Filter Expression goes here&lt;/span&gt;
            &lt;span class="kwrd"&gt;return&lt;/span&gt; entity =&amp;gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;//User does not have access to '/Customers' , throw AccessViolationException&lt;/span&gt;
        {
            &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; DataServiceException(403,
                &lt;span class="str"&gt;&amp;quot;Forbidden&amp;quot;&lt;/span&gt;,
                String.Format(&lt;span class="str"&gt;&amp;quot;User '{0}' cannot request data from '{1}' table&amp;quot;&lt;/span&gt;, loggedInUser, &lt;span class="str"&gt;&amp;quot;Customers&amp;quot;&lt;/span&gt;),
                &lt;span class="str"&gt;&amp;quot;en-US&amp;quot;&lt;/span&gt;);
        }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;











.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;











.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;When the Astoria server runtime throws the above exception , the 403 value specified above&amp;#160; gets turned into the response status code of the request 
  &lt;br /&gt;which caused this exception.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Ado.netDataServicesEfficientErrorHandlin_A066/StatusCodeInFiddler_1.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="StatusCodeInFiddler" border="0" alt="StatusCodeInFiddler" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Ado.netDataServicesEfficientErrorHandlin_A066/StatusCodeInFiddler_thumb_1.png" width="402" height="79" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;

&lt;p&gt;and the error message is serialized out to be in this format : &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;standalone&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;yes&amp;quot;&lt;/span&gt; ?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;error&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;code&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Forbidden&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;code&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;message&lt;/span&gt; &lt;span class="attr"&gt;xml:lang&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;en-US&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;User 'NoPermissions' cannot request data from 'Customers' table&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;message&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; 
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;error&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;At this point , the service has not lost any information that the service author intended to convey to a service consumer. 
  &lt;br /&gt;

  &lt;br /&gt;Now , lets consider the client library and how it handles this case. 

  &lt;br /&gt;Lets consider a query for the “Customers” set to which the currently logged-in user doesn't have permissions.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Customers customerEntity &lt;span class="kwrd"&gt;in&lt;/span&gt; northwindContext.CreateQuery&amp;lt;Customers&amp;gt;(&lt;span class="str"&gt;&amp;quot;Customers&amp;quot;&lt;/span&gt;) ) {
 &lt;span class="rem"&gt;//Do something with the customerEntity here&lt;/span&gt;
}&lt;/pre&gt;

&lt;p&gt;In this case, running the above code&amp;#160; would result in a DataServiceQueryException being thrown.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;System.Data.Services.Client.DataServiceQueryException: 
  An error occurred while processing this request. ---&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;        &lt;br /&gt;     System.Data.Services.Client.DataServiceClientException: 
      &lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;standalone&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;yes&amp;quot;&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;        &amp;lt;&lt;/span&gt;&lt;span class="html"&gt;error&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;code&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Forbidden&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;code&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;message&lt;/span&gt; &lt;span class="attr"&gt;xml:lang&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;en-US&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;User 'NoPermissions' cannot request data from 'Customers' table&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;message&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;      &amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;error&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Note that the DataServiceException thrown by the server is now set to the Message property of the InnerException of the DataServiceQueryException. 
  &lt;br /&gt;We do not de-serialize the DataServiceException into an exception type on the client side. 

  &lt;br /&gt;By default , since the exception is now a string on the client side , you don’t have direct&amp;#160; access to the information contained inside the Exception. 

  &lt;br /&gt;The information is all still there , just not easily accessible anymore. Since the error contract is &lt;a href="http://msdn.microsoft.com/en-us/library/dd541497(PROT.10).aspx"&gt;documented&lt;/a&gt; and follows a standard pattern , 

  &lt;br /&gt;we can easily write a visitor that de-serializes an exception object from the “Message” property&amp;#160; of the Inner Exception.&lt;/p&gt;

&lt;p&gt;One such de-serializer for Error contracts is shown at the bottom of this post 
  &lt;br /&gt;It contains two methods : 

  &lt;br /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;TryParse : which takes in an exception caused during Querying or updating via the client library and 
    &lt;br /&gt;returns a DataServiceException that was thrown by the Server &lt;/li&gt;

  &lt;li&gt;Throw : which takes in an exception caused during Querying or updating via the client library and 
    &lt;br /&gt;re-throws the DataServiceException that was thrown by the Server &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;script src="http://gist.github.com/227246.js"&gt;&lt;/script&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9922386" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Components/default.aspx">Components</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category></item><item><title>Please welcome the JAVA Client for ADO.NET Data Services</title><link>http://blogs.msdn.com/phaniraj/archive/2009/09/29/please-welcome-the-java-client-for-ado-net-data-services.aspx</link><pubDate>Tue, 29 Sep 2009 06:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9900583</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9900583.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9900583</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/interoperability/archive/2009/09/28/new-bridge-broadens-java-and-net-interoperability.aspx" mce_href="http://blogs.msdn.com/interoperability/archive/2009/09/28/new-bridge-broadens-java-and-net-interoperability.aspx"&gt;The new Java client&lt;/A&gt; joins a growing family of clients for ADO.NET Data Services, which include:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://aspnet.codeplex.com/Wiki/View.aspx?title=AJAX" mce_href="http://aspnet.codeplex.com/Wiki/View.aspx?title=AJAX"&gt;Ajax&lt;/A&gt; , &lt;A href="http://msdn.microsoft.com/en-us/magazine/cc794279.aspx" mce_href="http://msdn.microsoft.com/en-us/magazine/cc794279.aspx"&gt;Silverlight&lt;/A&gt; , &lt;A href="http://msdn.microsoft.com/en-us/library/system.data.services.client.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.data.services.client.aspx"&gt;.Net FX&lt;/A&gt; ,&lt;A href="http://aspnet.codeplex.com/Wiki/View.aspx?title=Dynamic%20Data" mce_href="http://aspnet.codeplex.com/Wiki/View.aspx?title=Dynamic%20Data"&gt;Dynamic Data&lt;/A&gt;, &lt;A href="http://blogs.msdn.com/interoperability/archive/2009/08/21/a-new-bridge-for-php-developers-to-net-through-rest-php-toolkit-for-ado-net-data-services.aspx" mce_href="http://blogs.msdn.com/interoperability/archive/2009/08/21/a-new-bridge-for-php-developers-to-net-through-rest-php-toolkit-for-ado-net-data-services.aspx"&gt;PHP&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;Here’s some documentation about the Java client &lt;A title=http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/287-restlet.html href="http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/287-restlet.html" mce_href="http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/287-restlet.html"&gt;http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/287-restlet.html&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9900583" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Do/default.aspx">Do</category></item><item><title>Using the ADO.NET Data Services Silverlight client library in x-domain and out of browser scenarios – II (Forms Authentication)</title><link>http://blogs.msdn.com/phaniraj/archive/2009/09/10/using-the-ado-net-data-services-silverlight-client-library-in-x-domain-and-out-of-browser-scenarios-ii-forms-authentication.aspx</link><pubDate>Thu, 10 Sep 2009 02:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9893382</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9893382.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9893382</wfw:commentRss><description>&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;A href="http://blogs.msdn.com/phaniraj/attachment/9893382.ashx" mce_href="http://blogs.msdn.com/phaniraj/attachment/9893382.ashx"&gt;Click here to download sample application&lt;/A&gt;&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the ADO.NET Data Services Silverlight client library in x-domain and out of browser scenarios – II (Forms Authentication) &lt;BR&gt;In this blog post, we will talk about using the Silverlight Client Library against a Data Service that is secured with Asp.Net Forms Authentication &lt;BR&gt;In short, the whole process of authenticating against a Forms Authentication protected Data Service looks like this. &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_8.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_thumb_3.png" width=729 height=303 mce_src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H3&gt;Server Setup &lt;/H3&gt;
&lt;OL&gt;
&lt;LI&gt;Setup Forms Authentication on the Data Service Server &lt;/LI&gt;
&lt;LI&gt;Enable the WCF Authentication Service by following the reference here : &lt;A href="http://msdn.microsoft.com/en-us/library/bb398990.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb398990.aspx"&gt;How to: Enable the WCF Authentication Service&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;Exclude the following resources from requiring authentication , &lt;/LI&gt;&lt;/OL&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;3.1 The WCF Authentication Service &lt;BR&gt;3.2 The ClientAccessPolicy.xml File &lt;BR&gt;Ex:&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;&amp;lt;!-- The ClientAccessPolicy.xml file is required for the client to confirm if the server allows X-Domain callers.&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;       This should be downloadable without authenticating--&amp;gt;&lt;/SPAN&gt;
 &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;location&lt;/SPAN&gt; &lt;SPAN class=attr&gt;path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clientaccesspolicy.xml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;authorization&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;allow&lt;/SPAN&gt; &lt;SPAN class=attr&gt;users&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="*"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;authorization&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;location&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
 &lt;SPAN class=rem&gt;&amp;lt;!--This should be downloadable without authenticating.--&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;location&lt;/SPAN&gt; &lt;SPAN class=attr&gt;path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="AuthenticationService.svc"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;authorization&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;allow&lt;/SPAN&gt; &lt;SPAN class=attr&gt;users&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="*"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;authorization&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;location&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;4. If the DataServiceHost does not have a global.asax file, add one to the project. &lt;BR&gt;5. In the Global.asax file, we need to listen on the &lt;A href="http://msdn.microsoft.com/en-us/library/system.web.applicationservices.authenticationservice.creatingcookie.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.web.applicationservices.authenticationservice.creatingcookie.aspx"&gt;AuthenticationService.CreatingCookie&lt;/A&gt; event to customize the FormsAuth Cookie that the service creates.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Why do we need to customize the FormsAuth cookie? &lt;BR&gt;&lt;/B&gt;The WCF Authentication service by default creates &lt;A href="http://msdn.microsoft.com/en-us/library/system.web.httpcookie.httponly.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.web.httpcookie.httponly.aspx"&gt;HTTPOnly&lt;/A&gt; Cookies. &lt;BR&gt;This means that the cookie isn’t accessible by client-script. &lt;BR&gt;It generally isn’t a problem when the client application is running in the same domain as the Website, &lt;BR&gt;as the browser handles cookie management for us transparently. &lt;BR&gt;When the client is not in the same domain as the Website, and we use the ClientHttpWebRequest networking stack, &lt;BR&gt;we are unable to access any cookies marked as HttpOnly. &lt;BR&gt;To work around this limitation, we recreate the FormsAuth cookie with HttpOnly set to false in the CreatingCookie event handler. &lt;BR&gt;For more details: &lt;A href="http://msdn.microsoft.com/en-us/library/bb398778.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb398778.aspx"&gt;How to: Customize the Authentication Cookie from the WCF Authentication Service&lt;/A&gt; &lt;BR&gt;Example code:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;protected&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Application_Start(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, EventArgs e)
{
&lt;SPAN class=rem&gt;//Handle the CreatingCookie event so that we can create a custom cookie with HttpOnly set to false.&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;//AuthenticationService.CreatingCookie on MSDN :&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;//http://msdn.microsoft.com/enus/library/system.web.applicationservices.authenticationservice.creatingcookie.aspx&lt;/SPAN&gt;
AuthenticationService.CreatingCookie += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler&amp;lt;CreatingCookieEventArgs&amp;gt;(CreateSilverlightCompatibleHttpCookie);
}&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// Creates a HttpCookie that can be read by the managed CookieContainer in ClientHttpWebRequest in Silverlight&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;param name="sender"&amp;gt;The calling context for this event&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;param name="e"&amp;gt;a property bag containing useful information about the HttpCookie to create&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; CreateSilverlightCompatibleHttpCookie(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, System.Web.ApplicationServices.CreatingCookieEventArgs e)
{
  &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; cookieVersion = 1;
  &lt;SPAN class=rem&gt;//The time at which the cookie was issued by the server&lt;/SPAN&gt;
  DateTime cookieIssueDate = DateTime.Now;
  &lt;SPAN class=rem&gt;//The relative time from now when the cookie will expire and the client will have to re-authenticate.&lt;/SPAN&gt;
  DateTime cookieExpiryDate = DateTime.Now.AddMinutes(30);
  &lt;SPAN class=rem&gt;//The Forms Auth ticket which uniquely identifies a user &lt;/SPAN&gt;
  &lt;SPAN class=rem&gt;//FormsAuthenticationTicket on MSDN : http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.aspx&lt;/SPAN&gt;
  FormsAuthenticationTicket ticket = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; FormsAuthenticationTicket
                (cookieVersion,
                 e.UserName,
                 cookieIssueDate,
                 cookieExpiryDate,
                 e.IsPersistent, &lt;SPAN class=rem&gt;/*Indicates whether the authentication cookie should be retained beyond the current session*/&lt;/SPAN&gt;
                 e.CustomCredential,
                 FormsAuthentication.FormsCookiePath);
 &lt;SPAN class=rem&gt;//Creates a string containing an encrypted forms-authentication ticket suitable for use in an HTTP cookie.&lt;/SPAN&gt;
 &lt;SPAN class=rem&gt;//FormsAuthentication.Encrypt on MSDN : http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.encrypt.aspx&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; encryptedTicket = FormsAuthentication.Encrypt(ticket);
  HttpCookie cookie = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
  &lt;SPAN class=rem&gt;//set HttpOnly to false so that the managed CookieContainer can read the FormsAuth cookie from the response.&lt;/SPAN&gt;
  cookie.HttpOnly = &lt;SPAN class=kwrd&gt;false&lt;/SPAN&gt;;
  cookie.Expires = cookieExpiryDate;
  HttpContext.Current.Response.Cookies.Add(cookie);
  e.CookieIsSet = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;
 }&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;H3&gt;Silverlight Client Setup&lt;/H3&gt;
&lt;P&gt;We will follow an adapter pattern which is responsible for logging in the user and injecting the FormsAuth cookie as the client library makes requests. &lt;BR&gt;To start with,&lt;B&gt; add a Service reference to the WCF Authentication service in the Silverlight Client application or use the one in the sample.&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The FormsAuthAdapter will use the client side proxy generated for the WCF Authentication service to login the user &lt;BR&gt;and hook into any attached DataServiceContext instance’s SendingRequest event to inject the FormsAuth cookie. &lt;BR&gt;An instance of the FormsAuthenticationAdapter is declared at the application level.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;partial&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; App : Application
{
&lt;SPAN class=rem&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// FormsAuthenticationAdapter instance to manage authentication against a WCF Authentication Service&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; FormsAuthenticationAdapter FormsAuthAdapter;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;This is initialized when the Application starts.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Application_Startup(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, StartupEventArgs e)
{
&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; authServiceUri = String.Empty;
&lt;SPAN class=rem&gt;//extract the AuthenticationService Uri from the App.XAML file&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.Resources.Contains(&lt;SPAN class=str&gt;"AuthenticationServiceUri"&lt;/SPAN&gt;))
{
authServiceUri = &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.Resources[&lt;SPAN class=str&gt;"AuthenticationServiceUri"&lt;/SPAN&gt;].ToString();
}
FormsAuthAdapter = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; FormsAuthenticationAdapter(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Uri(authServiceUri, UriKind.RelativeOrAbsolute));
&lt;SPAN class=rem&gt;//The FormsAuthCookieName  should be the same value as declared in the Web.config of the server&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;//ex: If your web.config on the server requiring Forms Authentication is :&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;//&amp;lt;authentication mode="Forms"&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;//  &amp;lt;forms loginUrl="LoginForm.aspx" name=".ASPXFormsAUTH" protection="All" path="/" /&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;//&amp;lt;/authentication&amp;gt;&lt;/SPAN&gt;
    FormsAuthAdapter.FormsAuthCookieName = &lt;SPAN class=str&gt;".ASPXFormsAUTH"&lt;/SPAN&gt;;
    &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.RootVisual = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; MainPage();
    &lt;SPAN class=rem&gt;//Uncomment the below 2 lines to show the Loginwindow on application startup&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;//LoginWindow login = new LoginWindow();&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;//login.Show();&lt;/SPAN&gt;
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;This is what our client application looks like: &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_thumb.png" width=580 height=455 mce_src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As you can see, along with the “Install me” button, we now have a “Login” button.&lt;/P&gt;
&lt;P&gt;When the page loads, we attach an instance of the DataServiceContext which we want to get the FormsAuth Cookie injected while &lt;BR&gt;making requests to the Data Service.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;//Attach the DataServiceContext instance so that we can inject the FormsAuth cookie for each request&lt;/SPAN&gt;
App.FormsAuthAdapter.Attach(publicationContext);
Where the Attach Method’s signature &lt;SPAN class=kwrd&gt;is&lt;/SPAN&gt; :
&lt;SPAN class=rem&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// Injects the FormsAuth cookie when the contextInstance makes a request to the DataService&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;param name="contextInstance"&amp;gt;The DataServiceContext instance to observe&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Attach(DataServiceContext contextInstance)&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;Clicking the login button on the main page opens up a ChildWindow instance that we created which emulates the Login Screen. &lt;/P&gt;
&lt;P&gt;Login button click handler:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; LoginUser(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, RoutedEventArgs e)
{
    LoginWindow login = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; LoginWindow();
    login.Show();
    &lt;SPAN class=rem&gt;//The LoginWindow only closes if Authentication succeeds&lt;/SPAN&gt;
    login.Closing += (s, eArgs) =&amp;gt;
    {
       &lt;SPAN class=rem&gt;/*If auth succeeds,hide the button*/&lt;/SPAN&gt;
       btnLogin.Visibility = Visibility.Collapsed;
    };
  }&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_thumb_2.png" width=582 height=429 mce_src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Usi.NETDataServicesSilverlightclientlibr_9C79/image_thumb_2.png"&gt;&lt;/A&gt; &lt;BR&gt;The LoginWindow’s “Login” button uses the application wide FormsAuthenticationAdapter instance, discussed above, to login the user. &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; LoginUser(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, RoutedEventArgs e)
{
App.FormsAuthAdapter.LoginAsync(txtUserName.Text, txtPassword.Password,
    (loginEventArgs) =&amp;gt;
    {
&lt;SPAN class=kwrd&gt;      if&lt;/SPAN&gt; (loginEventArgs.Result)
       {
         &lt;SPAN class=rem&gt;/*Login succeeded*/&lt;/SPAN&gt;
         &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.DialogResult = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;
       }
&lt;SPAN class=kwrd&gt;       else&lt;/SPAN&gt;
      {
         &lt;SPAN class=rem&gt;/*Login failed*/&lt;/SPAN&gt;
      }
    }
    );
}
The LoginAsync method’s signature &lt;SPAN class=kwrd&gt;is&lt;/SPAN&gt;:
  &lt;SPAN class=rem&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// Logs in the User and calls the LoginComplete handler&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;param name="userName"&amp;gt;UserName to login &amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;param name="passWord"&amp;gt;password for the user account&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=rem&gt;/// &amp;lt;param name="pLoginComplete"&amp;gt;Called when the login process is complete&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; LoginAsync(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; userName, &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; passWord, Action&amp;lt;LoginCompletedEventArgs&amp;gt; pLoginComplete)&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;&lt;BR&gt;Once the user types in his/her username and password and hits “Login” , the Login window hits the WCF authentication service &lt;BR&gt;and extracts the FormsAuth cookie from the response.When the client library makes a request to the Data Service , the FormsAuthenticationAdapter &lt;BR&gt;injects the FormsAuth cookie &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Common errors:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;1. You receive an ArgumentException when trying to set the cookie header in the SendingRequest event.&lt;/P&gt;
&lt;P&gt;a. System.ArgumentException occurred &lt;BR&gt;&amp;nbsp; Message="The 'Cookie' header cannot be modified directly.\r\nParameter name: name" &lt;BR&gt;&amp;nbsp; StackTrace: &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Net.WebHeaderCollection.ThrowOnRestrictedHeader(String name, String value) &lt;BR&gt;&amp;nbsp; InnerException: &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Resolution: &lt;/B&gt;The reason you get this is because the client library is using the classic networking stack (based on XmlHttpRequest) &lt;BR&gt;to make the request. In this case, the Cookie header isn’t accessible and the above exception is valid. &lt;BR&gt;This is probably the only case where we would ask you to set the HttpStack property on the Client library. &lt;BR&gt;To fix this: &lt;BR&gt;//Set the HttpStack on the client Context instance to force the client library &lt;/P&gt;
&lt;P&gt;//to use the ClientHttpWebRequest stack for network access &lt;BR&gt;publicationContext.HttpStack = HttpStack.ClientHttp;&lt;B&gt; &lt;BR&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Additional resources:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;How do I authenticate my users against the Active Directory from my Silverlight application? &lt;BR&gt;&lt;/B&gt;In ASP.NET Forms Authentication, the Membership provider is responsible for accessing the Credential store and validating the user name and password. &lt;BR&gt;By setting the Membership provider to be the ActiveDirectoryMembershipProvider , you can authenticate the user name and password the user enters &lt;BR&gt;with the credentials stored in Active Directory. For more details , please refer to this MSDN article :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms998347.aspx#paght000022_usingtheactivedirectorymembershipprovider" mce_href="http://msdn.microsoft.com/en-us/library/ms998347.aspx#paght000022_usingtheactivedirectorymembershipprovider"&gt;Using the ActiveDirectoryMembershipProvider&lt;/A&gt; &lt;BR&gt;&lt;B&gt;References :&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/dd470115(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd470115(VS.95).aspx"&gt;About ClientAccessPolicy.xml files&lt;/A&gt; &lt;BR&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb547119.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb547119.aspx"&gt;ASP.NET Application Services.&lt;/A&gt; &lt;BR&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa480476.aspx"&gt;ASP.NET Forms Authentication&lt;/A&gt; &lt;BR&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/sx3h274z.aspx" mce_href="http://msdn.microsoft.com/en-us/library/sx3h274z.aspx"&gt;Membership Providers&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9893382" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/phaniraj/attachment/9893382.ashx" length="3537053" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Forms+Authentication/default.aspx">Forms Authentication</category></item><item><title>Using the PHP Toolkit with ADO.NET Data Services</title><link>http://blogs.msdn.com/phaniraj/archive/2009/09/08/using-the-php-toolkit-with-ado-net-data-services.aspx</link><pubDate>Wed, 09 Sep 2009 01:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9892837</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9892837.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9892837</wfw:commentRss><description>&lt;ol&gt;   &lt;li&gt;&lt;a href="#Step1"&gt;Setup PHP on your windows machine&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="#Step2"&gt;Setup the PHP Toolkit &lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="#Step3"&gt;Setting up the PHP samples on IIS&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="#Step4"&gt;Running the sample ADO.NET Data Services&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="#Step5"&gt;PHP Sample Applications Walkthrough&lt;/a&gt; &lt;/li&gt; &lt;/ol&gt; &lt;a name="Step1"&gt;   &lt;h3&gt;Setup PHP on your windows machine&lt;/h3&gt; &lt;/a&gt;  &lt;p&gt;The following steps show you how to setup your windows machine to host PHP applications.    &lt;br /&gt;We will be talking about hosting the only supported ( by MS Support ) PHP CGI application on IIS .&lt;/p&gt;  &lt;p&gt;&lt;a href="http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/"&gt;Using FastCGI to Host PHP Applications on IIS 7.0&lt;/a&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;If you don’t find the &lt;strong&gt;php.ini-recommended &lt;/strong&gt;file , then rename the &lt;strong&gt;php.ini-development &lt;/strong&gt;file from your PHP folder. &lt;/li&gt;    &lt;li&gt;Once you are setup , if you get a HTTP 500 internal server error when browsing to the Php.ini file ,      &lt;br /&gt;then you need setup your timezone in the PHP.ini file . &lt;/li&gt;    &lt;li&gt;To do this , find the line in the php.ini file “date.timezone” . &lt;/li&gt;    &lt;li&gt;If it has a semi-colon before it , remove it . &lt;/li&gt;    &lt;li&gt;Set the date.timezone’s&amp;#160; value to be a valid value from this list : &lt;a href="http://nl3.php.net/manual/en/timezones.php"&gt;List of Supported Timezones&lt;/a&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In my php.ini , I have set the value to be &lt;strong&gt;date.timezone = &amp;quot;America/Los_Angeles&amp;quot;&lt;/strong&gt;&lt;/p&gt; &lt;a name="Step2"&gt;   &lt;h3&gt;Setup the PHP Toolkit&lt;/h3&gt; &lt;/a&gt;  &lt;p&gt;Follow the instructions on the codeplex site to setup your machine.    &lt;br /&gt;&lt;a href="http://phpdataservices.codeplex.com/Wiki/View.aspx?title=InstallationGuide"&gt;Installation and Configuration&lt;/a&gt;&lt;/p&gt; &lt;a name="Step3"&gt;   &lt;h3&gt;Setting up the PHP samples on IIS &lt;/h3&gt; &lt;/a&gt;  &lt;p&gt;I have copied the phpsamples folder from the downloaded phpdataservices1.0 folder    &lt;br /&gt;into the %SystemDrive%\inetpub\wwwroot folder.This is just so that I dont need to configure any permissions     &lt;br /&gt;for the IIS accounts.     &lt;br /&gt;Open the IIS manager by running “INETMGR” from the “run” prompt on the start menu&lt;/p&gt;  &lt;p&gt;Select the PHPSamples folder from the “Default Web Site”    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Samples_Not_Application_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Samples_Not_Application" border="0" alt="Samples_Not_Application" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Samples_Not_Application_thumb_1.png" width="146" height="154" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Right-Click the Virtual directory and select “Convert to Application”    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Samples_To_Application.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Samples_To_Application" border="0" alt="Samples_To_Application" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Samples_To_Application_thumb.png" width="204" height="240" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Confirm creating the virtual directory by&amp;#160; pressing “OK” in the next dialog that turns up    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Samples_To_Application_Confirm.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Samples_To_Application_Confirm" border="0" alt="Samples_To_Application_Confirm" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Samples_To_Application_Confirm_thumb.png" width="380" height="263" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This sets up the PHP applications that access the ADO.NET Data Service,    &lt;br /&gt;We still need to setup the actual Data Services that the PHP Samples access.&lt;/p&gt; &lt;a name="Step4"&gt;   &lt;h3&gt;Running the sample&amp;#160; ADO.NET Data Services&lt;/h3&gt; &lt;/a&gt;  &lt;p&gt;Find the ADODotNetDataServices folder in the PHPDataServices1.0 download.    &lt;br /&gt;This should be under the “samples” directory.     &lt;br /&gt;i.e PHPDataServices1.0\samples\ADODotNetDataServices     &lt;br /&gt;&lt;/p&gt;  &lt;h2&gt;Setup the Databases required for the project to run &lt;/h2&gt;  &lt;p&gt;1) Unzip the zipped database files from the &lt;/p&gt; PHPDataServices1.0\samples\ADODotNetDataServices\data folder.   &lt;br /&gt;2)&amp;#160;&amp;#160; Open up SQL management studio and Connect to your Database server   &lt;br /&gt;3) Right–click the databases node and select “Attach…”   &lt;br /&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Attach_DB_Step_1_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Attach_DB_Step_1" border="0" alt="Attach_DB_Step_1" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Attach_DB_Step_1_thumb.png" width="240" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;4) In the “Attach Database” dialog , press “Add” and select the unzipped “VideoGameStore_Data.mdf” file.    &lt;br /&gt;You will notice that once you select the MDF file&amp;#160; , the dialog will complain about a missing .ldf file.     &lt;br /&gt;5) This is a routine warning , select the ldf file row in the dialog and press “Remove”     &lt;br /&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Attach_DB_Step_2_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Attach_DB_Step_2" border="0" alt="Attach_DB_Step_2" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Attach_DB_Step_2_thumb_1.png" width="480" height="352" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;For the other database Northwind, you can use the sample database that are available from Download.Microsoft.com    &lt;br /&gt;Here’s a link to download the Northwind sample database : &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=06616212-0356-46A0-8DA2-EEBC53A68034&amp;amp;displaylang=en"&gt;Northwind and pubs Sample Databases for SQL Server 2000&lt;/a&gt;     &lt;br /&gt;Installation should be straight-forward as it comes with an MSI that is supposed to setup the database for you.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Disclaimer : I already had a copy of the Northwind database on my machine and didn’t use the installer above.      &lt;br /&gt;&lt;/strong&gt;&amp;#160; &lt;br /&gt;Once you have your databases setup , modify the respective connection strings web.config file from the ADODotNetDataServices project.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;NorthwindEntities&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style="color: red"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;metadata=res://*/NorthwindModel.csdl|res://*/NorthwindModel.ssdl|res://*/NorthwindModel.msl;&lt;br /&gt;                           provider=System.Data.SqlClient;&lt;br /&gt;                           provider connection string=&lt;/span&gt;&lt;span style="color: red"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;YOURCONNECTIONSTRINGHERE&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red"&gt;&amp;amp;quot;&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style="color: red"&gt;providerName&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;System.Data.EntityClient&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;add &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;VideoGameStoreEntities&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style="color: red"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;metadata=res://*/VideoGameStoreModel.csdl|res://*/VideoGameStoreModel.ssdl|res://*/VideoGameStoreModel.msl;&lt;br /&gt;                           provider=System.Data.SqlClient;&lt;br /&gt;                           provider connection string=&lt;/span&gt;&lt;span style="color: red"&gt;&amp;amp;quot;&lt;strong&gt;YOURCONNECTIONSTRINGHERE&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: red"&gt;&lt;strong&gt;&amp;amp;&lt;/strong&gt;quot;&lt;/span&gt;&amp;quot; &lt;br /&gt;         &lt;span style="color: red"&gt;providerName&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;System.Data.EntityClient&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;ol&gt;
  &lt;li&gt;Once you have the database and the Data Service setup, then configure the project to only run on the URL that the PHP Samples expect to find the Data Service on. 
    &lt;br /&gt;To do this : 

    &lt;br /&gt;In Visual Studio,Go to the properties of the Project. &lt;/li&gt;

  &lt;li&gt;Click on the “Web” Tab in the left-hand pane. &lt;/li&gt;

  &lt;li&gt;Under the “Servers” section , Select the “Specific Port”&amp;#160; option and enter “8080” for the port number. 
    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Setup_DataService_Select_Port.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Setup_DataService_Select_Port" border="0" alt="Setup_DataService_Select_Port" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Setup_DataService_Select_Port_thumb.png" width="640" height="205" /&gt;&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;Now, run the project in Visual studio and launch the PHP samples by browsing to the Index.php page 
      &lt;br /&gt;in the PHPSamples virtual directory.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;a name="Step5"&gt;
  &lt;h3&gt;PHP Sample Applications Walkthrough&lt;/h3&gt;
&lt;/a&gt;

&lt;p&gt;You should see this as the startup page when you run the PHP Samples 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/PHP_SAMPles_Screen1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PHP_SAMPles_Screen1" border="0" alt="PHP_SAMPles_Screen1" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/PHP_SAMPles_Screen1_thumb.png" width="640" height="415" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&lt;strong&gt;Demo&lt;/strong&gt; tab contents 

  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/PHP_SAMPles_Screen_Samples1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PHP_SAMPles_Screen_Samples1" border="0" alt="PHP_SAMPles_Screen_Samples1" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/PHP_SAMPles_Screen_Samples1_thumb.png" width="640" height="370" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the ADO.NET Data Services Editor Sample to see some pure PHP awesomeness 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/PHP_SAMPles_Screen2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PHP_SAMPles_Screen2" border="0" alt="PHP_SAMPles_Screen2" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/PHP_SAMPles_Screen2_thumb.png" width="640" height="209" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Here’s an editor page for the Customers Entity Set: 
  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Customers_Edit_Screen.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Customers_Edit_Screen" border="0" alt="Customers_Edit_Screen" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Customers_Edit_Screen_thumb.png" width="640" height="195" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;See that little text box over there ? 
  &lt;br /&gt;Yeah , it allows me to enter the Astoria URI operators like top , skip , filter to filter the rows bound to the grid below. 

  &lt;br /&gt;&lt;strong&gt;The gird is editable too &lt;/strong&gt;, Clicking on the “Detail” link in the first column of the grid brings up an editor for the customers 

  &lt;br /&gt;entity that was selected. 

  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Customers_Edit_Screen_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Customers_Edit_Screen_2" border="0" alt="Customers_Edit_Screen_2" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/UsingthePHPToolkitwithAD.NETDataServices_143D1/Customers_Edit_Screen_2_thumb.png" width="640" height="312" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So , there you have it , instructions to setup the samples and some tours of the sample applications. 
  &lt;br /&gt;Since I know next to nothing about PHP , I have a few questions for our PHP-Savvy users.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Which application framework(s) do you use&amp;#160; to build PHP applications? I know about CAKE and ZEND , any others? &lt;/li&gt;

  &lt;li&gt;Do you use a specific Validation framework or do you use the one that came with the&amp;#160; application framework? &lt;/li&gt;
&lt;/ol&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9892837" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Php/default.aspx">Php</category></item><item><title>Silverlight toolkit with ADO.NET Data services , Drill-down Charts using Astoria</title><link>http://blogs.msdn.com/phaniraj/archive/2009/06/11/silverlight-toolkit-with-ado-net-data-services-drill-down-charts-using-astoria.aspx</link><pubDate>Thu, 11 Jun 2009 10:12:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9726027</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9726027.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9726027</wfw:commentRss><description>&lt;p&gt;Download sample project here :&lt;/p&gt; &lt;iframe style="border-bottom: #dde5e9 1px solid; border-left: #dde5e9 1px solid; padding-bottom: 0px; background-color: #ffffff; margin: 3px; padding-left: 0px; width: 240px; padding-right: 0px; height: 26px; border-top: #dde5e9 1px solid; border-right: #dde5e9 1px solid; padding-top: 0px" marginheight="0" src="http://cid-925c2d2bb2d03c6b.skydrive.live.com/embedrow.aspx/SLToolkitAstoria/SLToolkitWithAstoria%7C_Chart%7C_DrillDown.zip" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;  &lt;p&gt;In part 2 of this series , we will look at using the Astoria client library to create a drill down chart using the chart types available in the Silverlight toolkit.    &lt;br /&gt;You can take a look at the complete samples for the Silverlight toolkit &lt;a href="http://www.codeplex.com/Silverlight/Wiki/View.aspx?title=Silverlight%20Toolkit%20Overview%20Part%202&amp;amp;referringTitle=Silverlight%20Toolkit%20Overview%20Part%201"&gt;here&lt;/a&gt;.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;This sample builds a UI that looks like this :&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Silverlighttoolk.NETDataservicesCharting_1428C/ChartDrillDownAstoria_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ChartDrillDownAstoria_2" border="0" alt="ChartDrillDownAstoria_2" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/Silverlighttoolk.NETDataservicesCharting_1428C/ChartDrillDownAstoria_2_thumb.png" width="462" height="474" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The Pie chart represents the distribution of Employees across departments.    &lt;br /&gt;Clicking on a specific piece of the pie&amp;#160; brings up the list of the employees in that department.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Binding the Pie chart      &lt;br /&gt;&lt;/strong&gt;The Chart control has a Pie series that has the DependentValuePath set to the Count of employees in the department     &lt;br /&gt;and the IndependentValuePath set to the name of the department.&lt;/p&gt;  &lt;p&gt;Setting the IndependentValuePath is straightforward ,set the IndependentValuePath to the “DepartMentName” property of the Department entity type. The DependentValuePath is a little tricky , as the Department entity doesnt contain aggregation information regarding the employees in the Department . But , it does have the employees as an ObservableCollection of Employee types . So , we can get the count by assigning the DependentValuePath to be the expression “Employees.Count” which gets the Count property of the IList. Unfortunately ,&amp;#160; this means that the Employees will also have to be downloaded when you bind the Departments. In another post , I will discuss how to lazy load the employees list and still get this aggregation.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;XAML for Pie Series in Chart &lt;/strong&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;chartingToolkit&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;Chart &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;x&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Name&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;chEmployeesByDepartment&amp;quot; &lt;br /&gt;       &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Title&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;# Employees/Department&amp;quot; &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;IsEnabled&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;true&amp;quot; &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Height&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;300&amp;quot;&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;chartingToolkit&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;Chart.Series&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;&amp;gt;
         &amp;lt;&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;chartingToolkit&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;PieSeries    &lt;br /&gt;                &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;x&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Name&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;lnSeries&amp;quot;
                &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;IndependentValuePath &lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;DepartMentName&amp;quot;
                &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;DependentValuePath &lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;Employees.Count&amp;quot;
                &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;SelectionChanged&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;DepartmentSelected&amp;quot;
                &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;IsSelectionEnabled &lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;=&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;True&amp;quot; &lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;&amp;gt;
         &amp;lt;/&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;chartingToolkit&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;PieSeries&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;chartingToolkit&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;Chart.Series&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;chartingToolkit&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;:&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;Chart&lt;/span&gt;&lt;span style="background: #10100d; color: #a1b070"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;
  &lt;br /&gt;&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;The function to bind the Pie series with the Department information&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="background: #10100d; color: #d6d694"&gt; private void &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;LoadDepartmentsAndEmployees&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;() {
    &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;DataServiceQuery&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Department&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;&amp;gt; &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;deptQueryWithEmployees &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;= &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;context&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;Departments&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;Expand&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;(&lt;/span&gt;&lt;span style="background: #10100d; color: #44b1e3"&gt;&amp;quot;Employees&amp;quot;&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;) &lt;br /&gt;                                 &lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;as &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;DataServiceQuery&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Department&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;;
    &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;deptQueryWithEmployees&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;QueryAndCall&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;(
       (&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;deparmentStatistics&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;) &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;=&amp;gt;  &lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;{
          &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;Dispatcher&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;BeginInvoke&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;(
           () &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;=&amp;gt;  &lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;{ 
                &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;PieSeries &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;series &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;= &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;chEmployeesByDepartment&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;Series&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;[&lt;/span&gt;&lt;span style="background: #10100d; color: cyan"&gt;0&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;] &lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;as &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;PieSeries&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;;
                &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;series&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;ItemsSource &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;= &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;deparmentStatistics&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;;
               }    
            );       
         }); }&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;Populating employee information when a department is selected in the Pie Series 
    &lt;br /&gt;&lt;/strong&gt;We need to setup the Pie Series in the chart control to allow selection of chart points&amp;#160; and hook into the 

  &lt;br /&gt;SelectionChanged event of the Pie Series. We do this by:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Setting IsSelectionEnabled to true on the Pie Series &lt;/li&gt;

  &lt;li&gt;Hooking up to the SelectionChanged event of the Pie Series &lt;/li&gt;
&lt;/ol&gt;

&lt;pre class="code"&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;        &lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;private void &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;DepartmentSelected&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;(&lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;object &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;sender&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;, &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;SelectionChangedEventArgs &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;e&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;) {  
            &lt;/span&gt;&lt;span style="background: #10100d; color: #ff0080"&gt;//Get the series that caused this  event to be raised
            &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;PieSeries &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;series &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;= &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;sender &lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;as &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;PieSeries&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;;
            &lt;/span&gt;&lt;span style="background: #10100d; color: #ff0080"&gt;//Get the current selected department in the Series
            &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Department &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;selectedDepartment &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;= &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;series&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;SelectedItem &lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;as &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;Department&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;;
            &lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;if &lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;(&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;selectedDepartment &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;!= &lt;/span&gt;&lt;span style="background: #10100d; color: #d6d694"&gt;null&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;) { 
                &lt;/span&gt;&lt;span style="background: #10100d; color: #ff0080"&gt;//Set the title of the data grid
                &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;lblSelectedDepartment&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;Text &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;= &lt;/span&gt;&lt;span style="background: #10100d; color: #009b00"&gt;String&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;Format&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;(&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;strSelectedDepartmentMessage&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;, &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;selectedDepartment&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;DepartMentName&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;);
                &lt;/span&gt;&lt;span style="background: #10100d; color: #ff0080"&gt;//Bind the employee grid with the employees for this department
                &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;dgEmployees&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;ItemsSource &lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;= &lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;selectedDepartment&lt;/span&gt;&lt;span style="background: #10100d; color: #80ff00"&gt;.&lt;/span&gt;&lt;span style="background: #10100d; color: #e8e8e8"&gt;Employees&lt;/span&gt;&lt;span style="background: #10100d; color: #a79a86"&gt;;
            }  
        }      &lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Download sample project here :&lt;/p&gt;
&lt;iframe style="border-bottom: #dde5e9 1px solid; border-left: #dde5e9 1px solid; padding-bottom: 0px; background-color: #ffffff; margin: 3px; padding-left: 0px; width: 240px; padding-right: 0px; height: 26px; border-top: #dde5e9 1px solid; border-right: #dde5e9 1px solid; padding-top: 0px" marginheight="0" src="http://cid-925c2d2bb2d03c6b.skydrive.live.com/embedrow.aspx/SLToolkitAstoria/SLToolkitWithAstoria%7C_Chart%7C_DrillDown.zip" frameborder="0" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9726027" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/DataServiceContext/default.aspx">DataServiceContext</category></item><item><title>ADO.NET Data Services Friendly Feeds , Mapping EDM Types - I</title><link>http://blogs.msdn.com/phaniraj/archive/2009/03/28/ado-net-data-services-friendly-feeds-mapping-edm-types-i.aspx</link><pubDate>Sun, 29 Mar 2009 00:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9516348</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9516348.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9516348</wfw:commentRss><description>&lt;P&gt;As I mentioned in my &lt;A href="http://blogs.msdn.com/phaniraj/archive/2009/03/18/introducing-web-friendly-feeds-aka-friendly-feeds.aspx" mce_href="http://blogs.msdn.com/phaniraj/archive/2009/03/18/introducing-web-friendly-feeds-aka-friendly-feeds.aspx"&gt;last blog post&lt;/A&gt; , here are some samples of how to map your entity properties to Atom/custom markup in the atom:entry element. &lt;BR&gt;You can apply Friendly Feed mappings on the EDM entity types by adding attributes to the CSDL of the Entity Data Model . &lt;BR&gt;We will focus on the kinds of mappings and how to achieve them . &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Pre-requisites &lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;1. To edit the CSDL , you will need to open the EDM model in Xml view .To do this , right-click the EDM model (.EDMX file ) in Visual Studio &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and select “Open with”-&amp;gt;”Xml Editor” . &lt;BR&gt;2. Add a reference to this namespace in the &lt;STRONG&gt;&amp;lt;edmx:ConceptualModels&amp;gt; &lt;/STRONG&gt;node&amp;nbsp; of the CSDL section in the EDMX file : &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ex: &lt;EM&gt;&lt;STRONG&gt;xmlns:m2="&lt;/STRONG&gt;&lt;/EM&gt;&lt;A title=http://schemas.microsoft.com/ado/2007/08/dataservices/metadata href="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" mce_href="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt;&lt;STRONG&gt;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&lt;/STRONG&gt;&lt;/A&gt;&lt;EM&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) Mapping to ATOM elements in the atom:entry payload :&amp;nbsp; &lt;BR&gt;&lt;/STRONG&gt;The EntityPropertyMapping (EPM) attribute has two constructors , one which binds the property to an Atom element in the feed , &lt;BR&gt;and another which binds the property to a custom element . We shall discuss the former in this section. &lt;/P&gt;
&lt;P&gt;For ATOM Mappings , the EPM markup has the following attributes .&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_SourcePath&lt;/B&gt;: The &lt;B&gt;m2:FC_SourcePath&lt;/B&gt; is used when &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a) The Property you are mapping exists in a base type and not on the current type . &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b) The property you are mapping exists in a complex type and not on the current type . &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_TargetPath &lt;/B&gt;: The atom:entry element to which this property has to be mapped to &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;m2:FC_ContentKind&lt;/STRONG&gt;: The content-type of the mapped&amp;nbsp; atom:entry element &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_KeepInContent &lt;/B&gt;: set this to false if you want the entity’s property value to turn up only in the mapped atom:entry element and not in the &amp;lt;contents&amp;gt; section. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Lets proceed&amp;nbsp; , using the same BlogPost&amp;nbsp; type that we &lt;A href="http://blogs.msdn.com/phaniraj/archive/2009/03/18/introducing-web-friendly-feeds-aka-friendly-feeds.aspx" mce_href="http://blogs.msdn.com/phaniraj/archive/2009/03/18/introducing-web-friendly-feeds-aka-friendly-feeds.aspx"&gt;discussed last time&lt;/A&gt; . &lt;BR&gt;This is the EDM Markup for the type : &lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;BlogPost&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;PropertyRef &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;BlogPostID&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Lat&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.Double&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Long&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.Double&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Published&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.DateTime&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;BlogPostID&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.Int32&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Title&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Body&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Author&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;PostURI&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;ContentSummary&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;IconUri&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;1. Map the “Title” property&amp;nbsp; of the BlogPost Entity type to the entry:title element &lt;/P&gt;
&lt;P&gt;When decorating EDM&amp;nbsp; types , the markup specifying the mapping goes on the property you are mapping , &lt;BR&gt;ex:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Title&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"
  &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;SyndicationTitle&lt;/SPAN&gt;"
  &lt;SPAN style="COLOR: red"&gt;m2:FC_EpmContentKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Plaintext&lt;/SPAN&gt;"
  &lt;SPAN style="COLOR: red"&gt;m2:FC_EpmKeepInContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;2. Map the “Author” property to entry:author element&amp;nbsp; &lt;/P&gt;
&lt;P&gt;This is what the markup would look like :&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Author&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"
           &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;SyndicationAuthorName&lt;/SPAN&gt;"
           &lt;SPAN style="COLOR: red"&gt;m2:FC_ContentKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Plaintext&lt;/SPAN&gt;"
           &lt;SPAN style="COLOR: red"&gt;m2:FC_KeepInContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;As described in&amp;nbsp; my previous blog post , you can map an Entity’s properties to the following atom:entry elements in the payload &lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=512&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;&lt;STRONG&gt;atom:entry Element &lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;&lt;B&gt;m2:FC_TargetPath &lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;entry:author/email &lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;SyndicationAuthorEmail&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;entry:author/name&lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;SyndicationAuthorName&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;entry:author/uri &lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;SyndicationAuthorUri&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;entry:published &lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;SyndicationPublished&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;entry:rights &lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;SyndicationRights&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;entry:summary &lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;SyndicationRights&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;entry:title &lt;/TD&gt;
&lt;TD vAlign=top width=310&gt;SyndicationTitle&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=400&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=204&gt;&lt;B&gt;Content-Kind &lt;/B&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=196&gt;&lt;STRONG&gt;m2:FC_ContentKind&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=204&gt;Plaintext&lt;/TD&gt;
&lt;TD vAlign=top width=196&gt;Plaintext&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=204&gt;Html&lt;/TD&gt;
&lt;TD vAlign=top width=196&gt;Html&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=204&gt;Xhtml&lt;/TD&gt;
&lt;TD vAlign=top width=196&gt;XHtml&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=204&gt;Default if not specified. &lt;/TD&gt;
&lt;TD vAlign=top width=196&gt;PlainText&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;STRONG&gt;2) Mapping to non-ATOM/custom&amp;nbsp; elements in the atom:entry payload :&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;For non-ATOM/custom Mappings , the EPM markup requires the following attributes.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_SourcePath&amp;nbsp;&amp;nbsp; &lt;/B&gt;: The property of the Entity Type whose value should be mapped &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_TargetPath&amp;nbsp; &lt;/B&gt;&amp;nbsp; : The xml path markup which describes the path to the custom markup this property should be mapped to . &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_NsPrefix&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/B&gt;: The xml prefix for the custom element/attribute that this property is mapped to. &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_NsUri&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/B&gt;: The xml namespace to which the custom element/attribute that this property is mapped should be under. &lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;m2:FC_KeepInContent &lt;/B&gt;: set this to false if you want the entity’s property value to turn up only in the mapped atom:entry element and not in the &amp;lt;contents&amp;gt; section. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The Xml Path syntax for custom mappings.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;this syntax is very logical and looks like the following . &lt;BR&gt;Lets say that you wanted to map a property to a custom element in markup that looks like this : &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;mycustomRoot&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;=”&lt;A href="http://www.mycustomformat.org/" mce_href="http://www.mycustomFormat.org"&gt;http://www.mycustomFormat.org&lt;/A&gt;”&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;customElement&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;property value goes here&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;customElement&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;mycustomRoot&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;









































.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;
for this example , &lt;BR&gt;&lt;B&gt;m2:FC_TargetPath&amp;nbsp; &lt;/B&gt;would be “&lt;SPAN class=html&gt;mycustomRoot&lt;/SPAN&gt;/&lt;SPAN&gt;customElement” &lt;BR&gt;&lt;B&gt;m2:FC_NsPrefix&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/B&gt;would be an empty string as this markup has no custom prefix. &lt;BR&gt;&lt;B&gt;m2:FC_NsUri&amp;nbsp; &lt;/B&gt;would be “&lt;A href="http://www.mycustomformat.org/" mce_href="http://www.mycustomFormat.org"&gt;http://www.mycustomFormat.org&lt;/A&gt;” &lt;BR&gt;&lt;B&gt;m2:FC_KeepInContent &lt;/B&gt;is subjective to whether you want to keep the property value in the &amp;lt;content&amp;gt; section or not.&lt;/SPAN&gt; 
&lt;P&gt;and now , lets say that you wanted to map a property to a custom attribute of an element in markup that looks like this : &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;me:&lt;/SPAN&gt;&lt;SPAN class=html&gt;mycustomRoot&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns:me&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.georss.org.georss"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;me:&lt;/SPAN&gt;&lt;SPAN class=html&gt;customElement&lt;/SPAN&gt; &lt;SPAN class=attr&gt;customAttribute&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="property value goes here"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/me:&lt;/SPAN&gt;&lt;SPAN class=html&gt;customElement&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/me:&lt;/SPAN&gt;&lt;SPAN class=html&gt;mycustomRoot&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;for this example , &lt;BR&gt;&lt;B&gt;m2:FC_TargetPath&amp;nbsp; &lt;/B&gt;would be &lt;A href="mailto:“mycustomRoot/customElement/@customAttribute" mce_href="mailto:“mycustomRoot/customElement/@customAttribute"&gt;“mycustomRoot/customElement/@customAttribute&lt;/A&gt;” &lt;BR&gt;&lt;B&gt;m2:FC_NsPrefix&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/B&gt;would be “me”. &lt;BR&gt;&lt;B&gt;m2:FC_NsUri&amp;nbsp; &lt;/B&gt;would be “http://www.mycustomFormat.org” &lt;BR&gt;&lt;B&gt;m2:FC_KeepContent &lt;/B&gt;is subjective to whether you want to keep the property value in the &amp;lt;content&amp;gt; section or not.&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;A note , the complexity of your custom markup has a direct effect on the performance costs&amp;nbsp; for Serialization/De-Serialization of the entity type . &lt;BR&gt;with this example , lets map the lat &amp;amp; long properties to geoRss markup ,which looks like this : &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;geo:lat&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns:geo&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.georss.org/georss"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;47.684&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;geo:lat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;geo:long&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns:geo&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.georss.org/georss"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;-122.122&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;geo:long&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Final type definition looks like this : &lt;BR&gt;&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;BlogPost&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;PropertyRef &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;BlogPostID&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Key&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;map the Lat property to the &amp;lt;geo:lat&amp;gt; element  &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Lat&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.Double&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;lat&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_NsUri&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.georss.org/georss&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_NsPrefix&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;geo&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_KeepContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;map the Long property to the &amp;lt;geo:long&amp;gt; element  &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Long&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.Double&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;long&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_NsUri&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;http://www.georss.org/georss&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_NsPrefix&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;geo&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_KeepContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;Map the “Title” property  of the BlogPost Entity type to the entry:title element &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Title&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmSyndicationTitle&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_ContentKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmPlaintext&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_KeepContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Body&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;Map the “Author” property to entry:author element  &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Author&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmSyndicationAuthorName&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_ContentKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmPlaintext&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_KeepContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;BlogPostID&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.Int32&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Published&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.DateTime&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;PostURI&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;ContentSummary&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;" &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;IconUri&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Edm.String&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Nullable&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;STRONG&gt;Special cases &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I . Complex type properties&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;[I’ll leave the type definitions as CLR types so that its easier to visualize the relations.] &lt;BR&gt;&lt;BR&gt;Consider the following model , &lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Address
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;public long &lt;/SPAN&gt;DoorNumber { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
        &lt;SPAN style="COLOR: blue"&gt;public string &lt;/SPAN&gt;Street { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
        &lt;SPAN style="COLOR: blue"&gt;public int &lt;/SPAN&gt;ZipCode { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
    }
    [&lt;SPAN style="COLOR: #2b91af"&gt;DataServiceKey&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"CustomerID"&lt;/SPAN&gt;)]
    &lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer
    &lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;public int &lt;/SPAN&gt;CustomerID { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
        &lt;SPAN style="COLOR: blue"&gt;public &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Address &lt;/SPAN&gt;myAddress { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
    }&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;BR&gt;and lets say that you wanted to map the property Street of the complex type Address when accessed through the &lt;BR&gt;entity type “Customer”&amp;nbsp; to the atom:title element ,&lt;/P&gt;
&lt;P&gt;this can be achieved via setting the &lt;STRONG&gt;EpmSourcePath &lt;/STRONG&gt;property to “Street”&amp;nbsp; . &lt;BR&gt;In this case , the Epm markup would look like this :&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Customer&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;Map the Street property of the Address complex type to the entry:title element &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
  &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Property &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;myAddress&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;MyModelNamespace.Address&lt;/SPAN&gt;"
&lt;STRONG&gt;            &lt;SPAN style="COLOR: red"&gt;me:EpmSourcePath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Street&lt;/SPAN&gt;"
&lt;/STRONG&gt;            &lt;SPAN style="COLOR: red"&gt;m2:FC_Atom&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmSyndicationTitle&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_ContentKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmPlaintext&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_KeepContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;
  &amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;other properties removed for brevity&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;STRONG&gt;II Mapping properties declared&amp;nbsp; on base type &lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;Consider this data model :&lt;/P&gt;&lt;PRE class=code&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;DataServiceKey&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"CustomerID"&lt;/SPAN&gt;)]
&lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer
&lt;/SPAN&gt;{
        &lt;SPAN style="COLOR: blue"&gt;public int &lt;/SPAN&gt;CustomerID { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
        &lt;SPAN style="COLOR: blue"&gt;public &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Address &lt;/SPAN&gt;myAddress { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
        &lt;SPAN style="COLOR: blue"&gt;public string &lt;/SPAN&gt;BaseTypeField { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
}

&lt;SPAN style="COLOR: blue"&gt;public class &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;DerivedCustomer &lt;/SPAN&gt;: &lt;SPAN style="COLOR: #2b91af"&gt;Customer
&lt;/SPAN&gt;{
  &lt;SPAN style="COLOR: blue"&gt;public string &lt;/SPAN&gt;DerivedTypeField { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }
}&lt;/PRE&gt;and you want to map a property declared on the Base type “Customer” on the derived type “DerivedCustomer” &lt;BR&gt;The EPM Markup would look like this : &lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;Map the "BaseTypeField" property of the base type "Customer" to the entry:title element &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;DerivedCustomer&lt;/SPAN&gt;" &lt;SPAN style="COLOR: red"&gt;BaseType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;MyModelNamespace.Customer&lt;/SPAN&gt;"
&lt;STRONG&gt;            &lt;SPAN style="COLOR: red"&gt;m2:FC_SourcePath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;BaseTypeField&lt;/SPAN&gt;"
&lt;/STRONG&gt;            &lt;SPAN style="COLOR: red"&gt;m2:FC_TargetPath&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmSyndicationAuthorName&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_ContentKind&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;EpmPlaintext&lt;/SPAN&gt;"
            &lt;SPAN style="COLOR: red"&gt;m2:FC_KeepContent&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
  &amp;lt;!-- &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;other properties removed for brevity&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;--&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityType&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;STRONG&gt;&lt;/STRONG&gt;
&lt;P&gt;&lt;STRONG&gt;Considerations for location&amp;nbsp; of EPM markup in EDM Schema&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Use the following guidelines to decide where in the EDM Schema you should add the attribute for either ATOM or custom Mappings,&lt;/P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=736&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=292&gt;&lt;STRONG&gt;Where is property defined ?&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=305&gt;&lt;STRONG&gt;Where do I apply the EPM attribute?&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=137&gt;&lt;STRONG&gt;SourcePath &lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=292&gt;Simple property on the Entity Type &lt;BR&gt;ex: &lt;BR&gt;“Title” property of “BlogPost” type above&lt;/TD&gt;
&lt;TD vAlign=top width=305&gt;&amp;lt;Property&amp;gt; node in the &amp;lt;Entitytype&amp;gt; markup&lt;/TD&gt;
&lt;TD vAlign=top width=137&gt;Not required&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=292&gt;Simple property on entity’s base type&lt;/TD&gt;
&lt;TD vAlign=top width=305&gt;&amp;lt;EntityType&amp;gt; node &lt;/TD&gt;
&lt;TD vAlign=top width=137&gt;Base type property name&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=292&gt;Complex Property on the Entity Type&lt;/TD&gt;
&lt;TD vAlign=top width=305&gt;Complex Types cannot be mapped directly &lt;/TD&gt;
&lt;TD vAlign=top width=137&gt;N/A&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=292&gt;Simple property defined on complex type which is a property on an Entity Type&lt;/TD&gt;
&lt;TD vAlign=top width=305&gt;&amp;lt;Property&amp;gt; node in the &amp;lt;EntityType&amp;gt; &lt;/TD&gt;
&lt;TD vAlign=top width=137&gt;Complex type’s simple property name&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Hope you enjoyed this post about applying Friendly Feeds mappings to EDMdata models. &lt;BR&gt;The second part of this post will discuss more special cases in EDM Models and troubleshooting failing mappings &lt;BR&gt;and also a sample project for EDM Friendly Feeds Mappings.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9516348" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Friendly+Feeds/default.aspx">Friendly Feeds</category></item><item><title>Versioning note , writing SL 3.0 applications with Astoria v1.5 Sl 2.0 SDK Library</title><link>http://blogs.msdn.com/phaniraj/archive/2009/03/25/versioning-note-writing-sl-3-0-applications-with-astoria-v1-5-sl-2-0-sdk-library.aspx</link><pubDate>Wed, 25 Mar 2009 05:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9506125</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9506125.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9506125</wfw:commentRss><description>&lt;P&gt;As part&amp;nbsp; of the v1.5 install, we also shipped a Silverlight 2.0 SDK library that is capable of talking to a v1.5 Astoria Service. &lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Did you know that you could use the Silverlight 2.0 client library we shipped as part of our v1.5 CTP1 release in Silverlight 3.0 applications?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;From a Silverlight SDK library point of view ,to use &lt;A href="http://blogs.msdn.com/MFlasko" mce_href="http://blogs.msdn.com/MFlasko"&gt;Mike Flasko’s&lt;/A&gt; words, ”we are nothing but user code”. &lt;BR&gt;We have no dependencies on the Runtime that have changed in SL 3.0 , &lt;STRONG&gt;&lt;EM&gt;yet&lt;/EM&gt;&lt;/STRONG&gt;. &lt;BR&gt;So , you can use the Silverlight 2.0 SDK library that we shipped in v1.5 CTP1 , by &lt;BR&gt;replacing the reference to “System.Data.Services.Client.dll” with “Microsoft.Data.Services.Client.dll”&lt;/P&gt;
&lt;P&gt;In your Silverlight project , &lt;BR&gt;&lt;BR&gt;1. If you already have a reference to “System.Data.Services.Client.dll” in your SIlverlight application , remove it .&lt;/P&gt;
&lt;P&gt;2. If you have the v1.5 CTP1 installed , the Silverlight client binaries are stored in the following location , &lt;BR&gt;&lt;SPAN style="BACKGROUND-COLOR: #ffcc00"&gt;%ProgramFiles%\ADO.NET Data Services V1.5 CTP1\sl_bin&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;3. Bring up the “Add Reference” window by right clicking the “References” node for the Silverlight 3.0 Project in Visual Studio.&lt;/P&gt;
&lt;P&gt;4. Use the “Browse” tab of the “Add Reference” window to browse to this location to add a reference to “Microsoft.Data.Services.Client.dll”.&lt;/P&gt;
&lt;P&gt;5. Rebuild and run the app . &lt;BR&gt;&lt;/P&gt;&lt;A&gt;&lt;/A&gt;
&lt;P&gt;&lt;STRONG&gt;What about Code-gen , &lt;BR&gt;&lt;/STRONG&gt;&lt;STRONG&gt;Can I point the Silverlight 3.0 application at a v1.5 CTP1 service and get all the binding &amp;amp; Friendly Feeds mappings generated in the Client types?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;No &lt;/STRONG&gt;, there is no integration for v1.5 codegeneration tools in Visual Studio for Sl 3.0 Projects . &lt;BR&gt;You will have to use the DataSvcUtil.exe tool from the following directory manually to generate the types with binding information for SL 3.0 projects .&lt;/P&gt;
&lt;P&gt;Location for DataSvcUtil.exe : &lt;SPAN style="BACKGROUND-COLOR: #ffcc00"&gt;%ProgramFiles%\ADO.NET Data Services V1.5 CTP1\bin&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;From a runtime perspective , is there any functionality in the v1.5 SL 2.0 library that is not present when the dll is inside a xap built with SL 3.0 tools ?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;No , none , everything should just work . If something doesn’t work , please leave a comment on this post or write to me at PhaniRaj At Microsoft Dot Com.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What about Silverlight 3 Out-Of-Browser applications ?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The Astoria Silverlight client library doesn’t yet work with Out of the Browser Silverlight applications.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9506125" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Versioning/default.aspx">Versioning</category></item><item><title>ADO.NET Data Services Silverlight Project Error : System.IO.FileNotFoundException</title><link>http://blogs.msdn.com/phaniraj/archive/2009/03/24/ado-net-data-services-silverlight-project-error-system-io-filenotfoundexception.aspx</link><pubDate>Tue, 24 Mar 2009 05:09:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9503162</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9503162.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9503162</wfw:commentRss><description>&lt;p&gt;Imagine this , you just downloaded the Astoria V1.5 CTP1 and are happily chugging along and decide to make a Silverlight Project    &lt;br /&gt;that uses the latest Silverlight client library to make some cool app.     &lt;br /&gt;You open an existing Silverlight app&amp;#160; /create a new Silverlight app ,     &lt;br /&gt;and generate the client types by running “Add Service Reference” from Visual Studio.     &lt;br /&gt;and write some code in the app and hit F5 to run the app .     &lt;br /&gt;Now , Instead of seeing the poetic beauty that is a Silverlight app built with Astoria , you see this : &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/cf33f5160cc9_FD05/M_D_S_C_Unhandled_Exception.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="M_D_S_C_Unhandled_Exception" border="0" alt="M_D_S_C_Unhandled_Exception" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/cf33f5160cc9_FD05/M_D_S_C_Unhandled_Exception_thumb.png" width="439" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Exception message is : &lt;/p&gt;  &lt;p&gt;System.IO.FileNotFoundException occurred    &lt;br /&gt;&amp;#160; Message=&amp;quot;Could not load file or assembly 'Microsoft.Data.Services.Client, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; The system cannot find the file specified.&amp;quot;     &lt;br /&gt;&amp;#160; StackTrace:     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at SilverlightProject1.Page..ctor()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at SilverlightProject1.App.Application_Startup(Object sender, StartupEventArgs e)     &lt;br /&gt;&amp;#160; InnerException: &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;strong&gt;What just happened ?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When the tools which generate the client code for an Astoria Service for Silverlight applications ran , they added a reference to the new client dll,    &lt;br /&gt;Microsoft.Data.Services.Client.dll with “Copy Local” set to false.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/cf33f5160cc9_FD05/M_D_S_C_Silverlight_Reference_1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="M_D_S_C_Silverlight_Reference" border="0" alt="M_D_S_C_Silverlight_Reference" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/cf33f5160cc9_FD05/M_D_S_C_Silverlight_Reference_thumb_1.png" width="276" height="484" /&gt;&lt;/a&gt; &lt;/p&gt; If your code looks like this,   &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;Page(){
InitializeComponent();
nwServiceReference.&lt;span style="color: #2b91af"&gt;BlogServiceProvider &lt;/span&gt;prov =
                &lt;span style="color: blue"&gt;new &lt;/span&gt;SilverlightProject1.nwServiceReference.&lt;span style="color: #2b91af"&gt;BlogServiceProvider&lt;/span&gt;(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;http://ServiceEndPoint&amp;quot;&lt;/span&gt;));
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;When the JIT compiler compiles your Page() constructor method, it scans the method, sees that it references a type named &lt;span style="color: #2b91af"&gt;BlogServiceProvider &lt;/span&gt;, and attempts to load Microsoft.Data.Services.Client.dll so that the reference can be resolved. 

  &lt;br /&gt;Now , Since we set Copy Local to false , the Client DLL is not copied into the XAP file ,and the Silverlight CLR cannot find the file , it throws the above exception. 

  &lt;br /&gt;We can verify by opening the xap file in winrar or some other archiving utility. 

  &lt;br /&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/cf33f5160cc9_FD05/Xap_No_CLient_Library.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Xap_No_CLient_Library" border="0" alt="Xap_No_CLient_Library" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/cf33f5160cc9_FD05/Xap_No_CLient_Library_thumb.png" width="644" height="327" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resolution :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In your Silverlight project, for the reference to “'Microsoft.Data.Services.Client.dll” ,&amp;#160; Set “Copy Local” to “True” and rebuild your Silverlight XAP. 
  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;What about “Update Service Reference”? 
    &lt;br /&gt;&lt;/strong&gt;Same issue , follow same resolution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When will this be fixed? 
    &lt;br /&gt;&lt;/strong&gt;We are tracking this issue and will release a fix in a future release of ADO.NET Data Services v1.5 &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9503162" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Batching Queries using the ADO.NET Data Services CLient library</title><link>http://blogs.msdn.com/phaniraj/archive/2009/03/15/batching-queries-using-the-ado-net-data-services-client-library.aspx</link><pubDate>Mon, 16 Mar 2009 00:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9479899</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9479899.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9479899</wfw:commentRss><description>&lt;P&gt;Did you know you could execute batch queries using the Data Services client library ?&lt;/P&gt;
&lt;P&gt;The API is ExecuteBatch for Synchronous access and Begin/End ExecuteBatch for asynchronous scenarios.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1) Batching a set of URI Queries .&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The ExecuteBatch API accepts an array of &lt;A href="http://msdn.microsoft.com/en-us/library/cc646604.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc646604.aspx"&gt;DataServiceRequest&lt;/A&gt; objects. &lt;BR&gt;Consider this example , you want to batch queries to be sent to the “Products” and “Categories” entity sets of a northwind service.&lt;/P&gt;
&lt;SCRIPT src="http://gist.github.com/113153.js"&gt;&lt;/SCRIPT&gt;

&lt;P&gt;&lt;STRONG&gt;2) Batching Linq Queries&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you want to use strongly types Linq queries instead of string based URI queries , you can use the linq support to generate the linq query &lt;/P&gt;
&lt;SCRIPT src="http://gist.github.com/113154.js"&gt;&lt;/SCRIPT&gt;

&lt;P&gt;&lt;STRONG&gt;3) How do I Identify the response if I make duplicate requests with the same ElementType ?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Consider this situation , You make 2 requests both of type DataServiceRequest&amp;lt;Products&amp;gt;&amp;nbsp; , how do you identify &lt;BR&gt;which response is for which request ?&lt;/P&gt;
&lt;P&gt;One of the scenarios&amp;nbsp; I can think of , is that the entity set contains multiple types related via inheritance .&lt;/P&gt;
&lt;P&gt;ex: Customers entity set contains instances of types HappyCustomers and HappierCustomers inheriting from Customers.&lt;/P&gt;
&lt;P&gt;The QueryOperationResponse type contains a &lt;A href="http://msdn.microsoft.com/en-us/library/system.data.services.client.queryoperationresponse.query(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.data.services.client.queryoperationresponse.query(VS.95).aspx"&gt;Query&lt;/A&gt; property which returns the DataServiceRequest that this response corresponds to .&lt;/P&gt;
&lt;P&gt;You can pass along the requests you made in the batch as a state to the callback and then compare the Query property of the QueryOperationResponse &lt;BR&gt;to match the response to the request.&lt;/P&gt;
&lt;P&gt;ex: &lt;/P&gt;
&lt;SCRIPT src="http://gist.github.com/113156.js"&gt;&lt;/SCRIPT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9479899" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/DataServiceContext/default.aspx">DataServiceContext</category></item><item><title>Working with Inheritance in Ado.net Data Services</title><link>http://blogs.msdn.com/phaniraj/archive/2008/12/23/working-with-inheritance-in-ado-net-data-services.aspx</link><pubDate>Wed, 24 Dec 2008 01:05:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9250996</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9250996.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9250996</wfw:commentRss><description>&lt;p&gt;I’ve seen this question quite often on the Astoria forums and wanted to write something down so that our users can gain from the discussions that go on in our forums.    &lt;br /&gt;We will discuss how one deals with entities ( tables / records / resources ) that participate in an inheritance hierarchy.     &lt;br /&gt;We shall take the following Data Model to discuss some key scenarios involving the Client Library. &lt;/p&gt;  &lt;pre class="darkcsharpcode"&gt;&lt;span class="rem"&gt;//Base Class&lt;/span&gt;
[DataServiceKey(&lt;span class="str"&gt;&amp;quot;PersonID&amp;quot;&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Person {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; PersonID { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    }

&lt;span class="rem"&gt;//Derived Class&lt;/span&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Employee : Person {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; EmployeeID { get; set; }
}&lt;/pre&gt;

&lt;p&gt;And you expose an IQueryable&amp;lt;Person&amp;gt; from your data source,&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; InheritedProvider {
        &lt;span class="kwrd"&gt;static&lt;/span&gt; List&amp;lt;Person&amp;gt; _people;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Initialize()  {
            _people = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;Person&amp;gt;(){
                &lt;span class="kwrd"&gt;new&lt;/span&gt; Person  {
                    PersonID =1,
                    Name=&lt;span class="str"&gt;&amp;quot;Phani&amp;quot;&lt;/span&gt;
                },
                &lt;span class="kwrd"&gt;new&lt;/span&gt; Employee {
                    PersonID =2,
                    EmployeeID =3,
                    Name =&lt;span class="str"&gt;&amp;quot;Raj&amp;quot;&lt;/span&gt;
                }
            };
        }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; IQueryable&amp;lt;Person&amp;gt; People {
            get {
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (_people == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
                    Initialize();
                &lt;span class="kwrd"&gt;return&lt;/span&gt; _people.AsQueryable&amp;lt;Person&amp;gt;();
            }
        }
    }&lt;/pre&gt;

&lt;p&gt;Browsing to the /People endpoint of the service gives you : &lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt; 

  &lt;br /&gt;&amp;lt;feed …Namespace Declarations… &amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;title type=&amp;quot;text&amp;quot;&amp;gt;People&amp;lt;/title&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;id&amp;gt;&lt;a href="http://localhost:13975/Inheritance.svc/People"&gt;http://localhost:13975/Inheritance.svc/People&lt;/a&gt;&amp;lt;/id&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;updated&amp;gt;2008-12-23T20:56:47Z&amp;lt;/updated&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;link rel=&amp;quot;self&amp;quot; title=&amp;quot;People&amp;quot; href=&amp;quot;People&amp;quot; /&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;entry&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;id&amp;gt;&lt;a href="http://localhost:13975/Inheritance.svc/People(1)"&gt;http://localhost:13975/Inheritance.svc/People(1)&lt;/a&gt;&amp;lt;/id&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;title type=&amp;quot;text&amp;quot; /&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;updated&amp;gt;2008-12-23T20:56:47Z&amp;lt;/updated&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;author&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;name /&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/author&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;link rel=&amp;quot;edit&amp;quot; title=&amp;quot;Person&amp;quot; href=&amp;quot;People(1)&amp;quot; /&amp;gt;&amp;#160;&amp;#160; &lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;category&lt;/span&gt; &lt;span class="attr"&gt;term&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Repro.Person&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;scheme&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;/pre&gt;

&lt;p&gt;&amp;lt;content type=&amp;quot;application/xml&amp;quot;&amp;gt; 
  &lt;br /&gt;&amp;#160; &amp;lt;m:properties&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;d:PersonID m:type=&amp;quot;Edm.Int32&amp;quot;&amp;gt;1&amp;lt;/d:PersonID&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;d:Name&amp;gt;Phani&amp;lt;/d:Name&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/m:properties&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/content&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/entry&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;entry&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;id&amp;gt;&lt;a href="http://localhost:13975/Inheritance.svc/People(2)"&gt;http://localhost:13975/Inheritance.svc/People(2)&lt;/a&gt;&amp;lt;/id&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;title type=&amp;quot;text&amp;quot; /&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;updated&amp;gt;2008-12-23T20:56:47Z&amp;lt;/updated&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;author&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;name /&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/author&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;link rel=&amp;quot;edit&amp;quot; title=&amp;quot;Person&amp;quot; href=&amp;quot;People(2)&amp;quot; /&amp;gt;&amp;#160; &lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;category&lt;/span&gt; &lt;span class="attr"&gt;term&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Repro.Employee&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;scheme&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160; &amp;lt;content type=&amp;quot;application/xml&amp;quot;&amp;gt; 
  &lt;br /&gt;&amp;#160; &amp;lt;m:properties&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;d:PersonID m:type=&amp;quot;Edm.Int32&amp;quot;&amp;gt;2&amp;lt;/d:PersonID&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;d:Name&amp;gt;Raj&amp;lt;/d:Name&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;d:EmployeeID m:type=&amp;quot;Edm.Int32&amp;quot;&amp;gt;3&amp;lt;/d:EmployeeID&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/m:properties&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/content&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/entry&amp;gt; 

  &lt;br /&gt;&amp;#160; &amp;lt;/feed&amp;gt; &lt;/p&gt;

&lt;p&gt;As you can see , the &amp;lt;Category&amp;gt; element of an &amp;lt;entry&amp;gt; element represents the Entity Type that this &amp;lt;entry&amp;gt; represents. 
  &lt;br /&gt;&lt;/p&gt;

&lt;h5&gt;How does this help one with working with against an Entity Set using Inheritance ?&lt;/h5&gt;

&lt;p&gt;Consider the following snippet of Client Code :&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;DataServiceContext dsc = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataServiceContext(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;&amp;quot;URI_TO_DATASERVICE&amp;quot;&lt;/span&gt;));
Employee newEmployee = &lt;span class="kwrd"&gt;new&lt;/span&gt; Employee() {Name = &lt;span class="str"&gt;&amp;quot;Peter Qian&amp;quot;&lt;/span&gt;};
dsc.AddObject(&lt;span class="str"&gt;&amp;quot;People&amp;quot;&lt;/span&gt;, newEmployee);
dsc.SaveChanges();&lt;/pre&gt;
Can you guess what is wrong with this ? 

&lt;br /&gt;

&lt;br /&gt;Yep, since the client library sees that you are trying to insert a Person Entity , we put the Entity Type as “Person” 

&lt;br /&gt;in the payload , i.e , the above operation results in the payload : 

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;entry&lt;/span&gt; &lt;span class="attr"&gt;xmlns:d&lt;/span&gt;&lt;span class="kwrd"&gt;=&lt;a href="http://schemas.microsoft.com/ado/2007/08/dataservices"&gt;http://schemas.microsoft.com/ado/2007/08/dataservices&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="attr"&gt;       xmlns:m&lt;/span&gt;&lt;span class="kwrd"&gt;=&lt;a href="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="attr"&gt;       xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2005/Atom&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;updated&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;2008-12-23T21:23:38.5935141Z&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;updated&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;content&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;application/xml&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;m:properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;d:EmployeeID&lt;/span&gt; &lt;span class="attr"&gt;m:type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.Int32&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;d:EmployeeID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;d:Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Peter Qian&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;d:Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;d:PersonID&lt;/span&gt; &lt;span class="attr"&gt;m:type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.Int32&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;d:PersonID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;m:properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;entry&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;br /&gt;

&lt;p&gt;And this causes the Server to respond with : 
  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;standalone&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;yes&amp;quot;&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;error&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;code&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;code&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;message&lt;/span&gt; &lt;span class="attr"&gt;xml:lang&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;en-US&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Error processing request stream. 
    Type information must be specified for types that take part in inheritance.&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;message&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;error&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;This error is because , as you can see in the request payload , the &amp;lt;category&amp;gt; element which specifies the Entity Type is missing form the Request Payload. 
  &lt;br /&gt;Since the Client library doesn’t resolve the Names/Types of the Entities for you , it provides you hooks to customize the name/type resolution 

  &lt;br /&gt;so that the right entity type is specified in the payloads.&lt;/p&gt;

&lt;h5&gt;Why can’t the Client library do this automatically ?&lt;/h5&gt;

&lt;p&gt;Main reason , Since we allow POCO , the type hierarchy of entities on the client can be different compared to the server. 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;In your client code , set the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.resolvename(VS.95).aspx" target="_blank"&gt;ResolveName&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.resolvetype.aspx" target="_blank"&gt;ResolveType&lt;/a&gt; Properties on the&amp;#160; DataServiceContext instance to 

  &lt;br /&gt;override the default type resolution behavior. 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;ex :&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;DataServiceContext dsc = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataServiceContext(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;&amp;quot;URI_TO_DATASERVICE&amp;quot;&lt;/span&gt;));
dsc.ResolveName = &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(Type entityType) {
     &lt;span class="kwrd"&gt;return&lt;/span&gt; entityType.FullName.Replace(&lt;span class="str"&gt;&amp;quot;&amp;lt;ClientNamespace&amp;gt;&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;&amp;lt;ServerNamespace&amp;gt;&amp;quot;&lt;/span&gt;);
};
dsc.ResolveType = &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt; entitySetName) {
      &lt;span class="kwrd"&gt;return&lt;/span&gt; Type.GetType(entitySetName);
};
Employee newEmployee = &lt;span class="kwrd"&gt;new&lt;/span&gt; Employee() {Name = &lt;span class="str"&gt;&amp;quot;Peter Qian&amp;quot;&lt;/span&gt;};
dsc.AddObject(&lt;span class="str"&gt;&amp;quot;People&amp;quot;&lt;/span&gt;, newEmployee);
dsc.SaveChanges();&lt;/pre&gt;
Since we provide the right Entity Type Name in the ResolveName property , the right Entity Type 

&lt;br /&gt;is placed in the payload. 

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;entry&lt;/span&gt; &lt;span class="attr"&gt;xmlns:d&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices&amp;quot;&lt;/span&gt;            
&lt;span class="attr"&gt;       xmlns:m&lt;/span&gt;&lt;span class="kwrd"&gt;=&lt;a href="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="attr"&gt;       xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2005/Atom&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;category&lt;/span&gt; &lt;span class="attr"&gt;scheme&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices/scheme&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;term&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ServerNamespace.Employee&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;updated&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;2008-12-23T21:52:44.8021175Z&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;updated&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;content&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;application/xml&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;m:properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;d:EmployeeID&lt;/span&gt; &lt;span class="attr"&gt;m:type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.Int32&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;d:EmployeeID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;d:Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Peter Qian&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;d:Name&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;d:PersonID&lt;/span&gt; &lt;span class="attr"&gt;m:type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.Int32&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;d:PersonID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;m:properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;entry&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;br /&gt;Hope this helps . 

&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9250996" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/DataServiceContext/default.aspx">DataServiceContext</category></item><item><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><pubDate>Fri, 12 Dec 2008 02:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9199026</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9199026.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9199026</wfw:commentRss><description>&lt;P&gt;This post is inspired by this forum thread :&lt;A href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/b7a9e01d-c5c2-4478-8f01-00f7f6e0f75f" target=_blank mce_href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/b7a9e01d-c5c2-4478-8f01-00f7f6e0f75f"&gt;Data services client -- exception on saveChanges&lt;/A&gt;&lt;/P&gt;
&lt;H4&gt;Problem Statement &lt;/H4&gt;&lt;BR&gt;
&lt;P&gt;I have added some custom proeprties to the Entity Types Generated by DataSvcUtil.exe /Add Service Reference / Hand Coded , &lt;BR&gt;these properties do not exist on the server and should not be sent to the server . &lt;BR&gt;When I try to save an object of a Type which has custom client-Side only properties to the Data Service using AddObject and SaveChanges, &lt;BR&gt;I get the following error :&lt;/P&gt;&lt;PRE class=csharpcode&gt;Error processing request stream. The property name &lt;SPAN class=str&gt;'{PropertyName}'&lt;/SPAN&gt; specified &lt;SPAN class=kwrd&gt;for&lt;/SPAN&gt; type '{TypeName} &lt;SPAN class=kwrd&gt;is&lt;/SPAN&gt; not valid&lt;/PRE&gt;
&lt;P&gt;This error is basically from the server telling the client library that its sending a payload which does not seem to match the definition &lt;BR&gt;of the Entity Type on the server. &lt;BR&gt;&lt;BR&gt;We can solve this problem by customizing the Payload that the client generates when it sends the entity to the server. &lt;BR&gt;The DataServiceContext exposes an event called &lt;A href="http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.writingentity.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.writingentity.aspx"&gt;WritingEntity&lt;/A&gt; that is fired right before we send the payload over the wire.&lt;/P&gt;
&lt;P&gt;Its argumentlist contains &lt;A href="http://msdn.microsoft.com/en-us/library/system.data.services.client.readingwritingentityeventargs.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.data.services.client.readingwritingentityeventargs.aspx"&gt;ReadingWritingEntityEventArgs&lt;/A&gt; which gives you access to the Entity Instance being Serialized ( e.Entity )&amp;nbsp; &lt;BR&gt;and the ATOM Payload (e.Data ) we are about to send to the Server.&lt;/P&gt;
&lt;H5&gt;Removing a property from the ATOM Payload that is being sent to the server.&lt;/H5&gt;&lt;PRE class=darkcsharpcode&gt;&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; dataContext_WritingEntity(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, ReadingWritingEntityEventArgs e) {

    &lt;SPAN class=rem&gt;// e.Data gives you the XElement for the Serialization of the Entity &lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;//Using XLinq  , you can  add/Remove properties to the element Payload  &lt;/SPAN&gt;
    XName xnEntityProperties = XName.Get(&lt;SPAN class=str&gt;"properties"&lt;/SPAN&gt;, e.Data.GetNamespaceOfPrefix(&lt;SPAN class=str&gt;"m"&lt;/SPAN&gt;).NamespaceName);
    XElement xePayload = e.Data.Descendants().Where&amp;lt;XElement&amp;gt;(xe =&amp;gt; xe.Name == xnEntityProperties).First&amp;lt;XElement&amp;gt;();
   &lt;SPAN class=rem&gt;//The XName of the property we are going to remove from the payload&lt;/SPAN&gt;
    XName xnProperty = XName.Get(“{PropertyName}”, e.Data.GetNamespaceOfPrefix(&lt;SPAN class=str&gt;"d"&lt;/SPAN&gt;).NamespaceName);

    &lt;SPAN class=rem&gt;//Get the Property of the entity  you don't want sent to the server&lt;/SPAN&gt;
    XElement xeRemoveThisProperty = xePayload.Descendants().Where&amp;lt;XElement&amp;gt;(xe =&amp;gt; xe.Name == xnProperty).First&amp;lt;XElement&amp;gt;();
    &lt;SPAN class=rem&gt;//Remove this property from the Payload sent to the server &lt;/SPAN&gt;
     xeRemoveThisProperty.Remove();

     }
}&lt;/PRE&gt;
&lt;P&gt;Generalizing this further , we want to make it easier to customize the serialization of multiple entity types without having to write &lt;BR&gt;multiple copies of the WritingEntity event handler. &lt;BR&gt;We will add an attribute that specfies that a certain CLR property should not be serialized in the ATOM Payload when the client library &lt;BR&gt;sends the entity to the server.&lt;/P&gt;&lt;PRE class=darkcsharpcode&gt;    &lt;SPAN class=rem&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;/// Properties marked with this Attribute are not serialized in the payload when sent to the server&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
    [AttributeUsage(AttributeTargets.Property)]
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; DoNotSerializeAttribute : Attribute
    {
    }&lt;/PRE&gt;
&lt;P&gt;Now , we change the WritingEntity Event handler to remove any property&amp;nbsp; that has this attribute on it . &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;PRE class=darkcsharpcode&gt;        &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; DataServiceContextEx_WritingEntity(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, ReadingWritingEntityEventArgs e)
        {
            &lt;SPAN class=rem&gt;// e.Data gives you the XElement for the Serialization of the Entity &lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;//Using XLinq  , you can  add/Remove properties to the element Payload  &lt;/SPAN&gt;
            XName xnEntityProperties = XName.Get(&lt;SPAN class=str&gt;"properties"&lt;/SPAN&gt;, e.Data.GetNamespaceOfPrefix(&lt;SPAN class=str&gt;"m"&lt;/SPAN&gt;).NamespaceName);
            XElement xePayload = &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;;
            &lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; (PropertyInfo property &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; e.Entity.GetType().GetProperties())
            {
                &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt;[] doNotSerializeAttributes = property.GetCustomAttributes(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(DoNotSerializeAttribute), &lt;SPAN class=kwrd&gt;false&lt;/SPAN&gt;);
                &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (doNotSerializeAttributes.Length &amp;gt; 0)
                {
                    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (xePayload == &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;)
                    {
                        xePayload = e.Data.Descendants().Where&amp;lt;XElement&amp;gt;(xe =&amp;gt; xe.Name == xnEntityProperties).First&amp;lt;XElement&amp;gt;();
                    }
                    &lt;SPAN class=rem&gt;//The XName of the property we are going to remove from the payload&lt;/SPAN&gt;
                    XName xnProperty = XName.Get(property.Name, e.Data.GetNamespaceOfPrefix(&lt;SPAN class=str&gt;"d"&lt;/SPAN&gt;).NamespaceName);
                    &lt;SPAN class=rem&gt;//Get the Property of the entity  you don't want sent to the server&lt;/SPAN&gt;
                    XElement xeRemoveThisProperty = xePayload.Descendants().Where&amp;lt;XElement&amp;gt;(xe =&amp;gt; xe.Name == xnProperty).First&amp;lt;XElement&amp;gt;();
                    &lt;SPAN class=rem&gt;//Remove this property from the Payload sent to the server &lt;/SPAN&gt;
                    xeRemoveThisProperty.Remove();
                }
            }
        }&lt;/PRE&gt;
&lt;P&gt;We can encapsulate this functionality into its own class and any DataServiceContext type that inherits from this class should be able to &lt;BR&gt;inherit this functionality too . &lt;BR&gt;Complete Source Code :&lt;/P&gt;
&lt;SCRIPT src="http://gist.github.com/113147.js" mce_src="http://gist.github.com/113147.js"&gt;&lt;/SCRIPT&gt;

&lt;H4&gt;Using this in your applications : &lt;/H4&gt;
&lt;P&gt;Create a partial class with the same name as shown above and include it in your application to get this behavior.&lt;/P&gt;
&lt;P&gt;Attribute your types with the DoNotSerializeAttribute&amp;nbsp; attribute so that this property is not serialized. &lt;BR&gt;&lt;/P&gt;&lt;PRE class=darkcsharpcode&gt; &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; TestType
    {
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; ID { get; set; }
        &lt;SPAN class=rem&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=rem&gt;/// This Property is client-only , should not be sent to the server&lt;/SPAN&gt;
        &lt;SPAN class=rem&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
        [DoNotSerialize]
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; ClientOnlyProperty { get; set; }
    }&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9199026" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Prototype/default.aspx">Prototype</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/DataServiceContext/default.aspx">DataServiceContext</category></item><item><title>Working with associations in ADO.NET Data Services , Part 2</title><link>http://blogs.msdn.com/phaniraj/archive/2008/10/23/working-with-associations-in-ado-net-data-services-part-2.aspx</link><pubDate>Fri, 24 Oct 2008 00:01:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9013687</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9013687.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9013687</wfw:commentRss><description>&lt;p&gt;In part 2 ,we will talk about how to use the client library to deal with :&lt;/p&gt;  &lt;h1&gt;1..N Associations&lt;/h1&gt;  &lt;p&gt;This is the case of entities associated with each other 1..N . An example from Northwind is the relation between Categories and Products Entities. &lt;/p&gt;  &lt;p&gt;An instance of the Categories entity type should have associated Products entities, this is another way of saying “ A row in the Products table should have links to a row in the Categories table”.    &lt;br /&gt;In case of 1..N relations , the left( child ) ends of the association are expressed as Collection properties on the right ( parent ) end of the relation.     &lt;br /&gt;This is shown in the metadata of the service as :&lt;/p&gt;  &lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;EntityType&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Categories&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;&amp;lt;!-- Primary Key--&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Key&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;PropertyRef&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CategoryID&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Key&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="rem"&gt;&amp;lt;!--Primitive Properties--&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Property&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CategoryID&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.Int32&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Nullable&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Property&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CategoryName&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.String&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Nullable&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Property&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Description&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.String&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Nullable&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Property&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Picture&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Edm.Binary&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Nullable&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
 &lt;span class="rem"&gt;&amp;lt;!-- Child Entity Set--&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;NavigationProperty&lt;/span&gt; 
        &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Products&amp;quot;&lt;/span&gt; 
        &lt;span class="attr"&gt;Relationship&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;northwind.FK_Products_Categories&amp;quot;&lt;/span&gt; 
        &lt;span class="attr"&gt;FromRole&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Categories&amp;quot;&lt;/span&gt; 
        &lt;span class="attr"&gt;ToRole&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Products&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;EntityType&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;This leads the client utility( DataSvcUtil.exe ) to generate a type Individual which has instances of types Customer and Contact as Properties.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The generated class on the client looks like this : 
  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Categories {
  &lt;span class="kwrd"&gt;public&lt;/span&gt; global::System.Collections.ObjectModel.Collection&amp;lt;Products&amp;gt; Products {
            get {
                &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;._Products;
            }
            set {
                &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;value&lt;/span&gt; != &lt;span class="kwrd"&gt;null&lt;/span&gt;))
                {
                    &lt;span class="kwrd"&gt;this&lt;/span&gt;._Products = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
                }
            }
        }
}&lt;/pre&gt;

&lt;p&gt;Now that we have set the stage, lets look at how one would use the client library to interact with the related types.&lt;/p&gt;

&lt;h5&gt;Creating the link between the entities &lt;/h5&gt;

&lt;p&gt;You have new instances of Individual , Contact and Customer and you want to persist the new entities and their relation to the store. &lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;DataServiceContext dsc = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataServiceContext(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;&amp;quot;http://ServiceEndpoint&amp;quot;&lt;/span&gt;));
Categories freeProductsCategory = &lt;span class="kwrd"&gt;new&lt;/span&gt; Categories()
{
    CategoryName = &lt;span class="str"&gt;&amp;quot;Free Products&amp;quot;&lt;/span&gt;,
    Description = &lt;span class="str"&gt;&amp;quot;These products are free&amp;quot;&lt;/span&gt;,
};
Products freeHeadPhones = Products.CreateProducts(0, &lt;span class="str"&gt;&amp;quot;Free Headphones&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;false&lt;/span&gt;);
Products freeZune = Products.CreateProducts(1, &lt;span class="str"&gt;&amp;quot;Free Zune&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;false&lt;/span&gt;);

dsc.AddObject(&lt;span class="str"&gt;&amp;quot;Categories&amp;quot;&lt;/span&gt;, freeProductsCategory);
dsc.AddObject(&lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, freeHeadPhones);
dsc.AddObject(&lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, freeZune);&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Now what ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since the entities are created and added to the store can’t I just set the Customer and Contact Property to the Individual object and that will save the relation ? 
  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;freeProductsCategory.Products.Add(freeHeadPhones);
freeProductsCategory.Products.Add(freeZune);
dsc.SaveChanges();&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Shouldn’t this be enough ? 
  &lt;br /&gt;Nope , that’s not enough to save the relation to the store. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;strong&gt;Why ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Remember that the client context only gives you POCO access to entities in the store and any new entities that you create. 
  &lt;br /&gt;The Client context &lt;strong&gt;does not track any relations &lt;/strong&gt;unless you &lt;strong&gt;explicitly ask it to do so !&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Neat&amp;#160; , now how do I ask it to do that ? &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You use the AddLink method defined on the context. 
  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;dsc.AddLink(freeProductsCategory, &lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, freeHeadPhones);
dsc.AddLink(freeProductsCategory, &lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, freeZune);&lt;/pre&gt;

&lt;p&gt;The signature and the intent of the SetLink method is lucid , it binds 2 entities into a relation , its kinda like a priest at a wedding, 
  &lt;br /&gt;This is what it looks like .. 

  &lt;br /&gt;

  &lt;br /&gt;AddLink ( Parentinstance ,”ChildPropertyName”,ChildInstance)&lt;/p&gt;

&lt;h5&gt;&lt;strong&gt;Deleting the parent entity&lt;/strong&gt;&lt;/h5&gt;

&lt;p&gt;Deleting the parent entity means that the relations with the child entities are also removed. 
  &lt;br /&gt;Think of this as the argument of “How do I delete an entity that has 1..1 links with other&amp;#160;&amp;#160; entities?” 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens if I delete the parent entity without deleting the links ?&lt;/strong&gt;&lt;/p&gt;
It depends on your store . If your database is configured to do a cascade delete on deletion of the parent entity ,you might get away with deleting the entity without removing the links 

&lt;p&gt;The right way to delete the entity is to remove all the links it has with the child entities and then delete the entity itself. 
  &lt;br /&gt;The code would look like this.. 

  &lt;br /&gt;&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;DataServiceContext dsc = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataServiceContext(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;&amp;quot;http://ServiceEndpoint&amp;quot;&lt;/span&gt;));
&lt;span class="rem"&gt;//Load an existing parent&lt;/span&gt;
Categories freeProductsCategory = dsc&lt;br /&gt;                                  .CreateQuery&amp;lt;Categories&amp;gt;(&lt;span class="str"&gt;&amp;quot;Categories&amp;quot;&lt;/span&gt;)
                                  .Where(cat =&amp;gt; cat.CategoryName == &lt;span class="str"&gt;&amp;quot;Free Products&amp;quot;&lt;/span&gt;)
                                  .First();
&lt;span class="rem"&gt;//Load all the related child Entities&lt;/span&gt;
dsc.LoadProperty(freeProductsCategory, &lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;);

&lt;span class="rem"&gt;//Delete the links with each of the child entities&lt;/span&gt;
&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Products freeProduct &lt;span class="kwrd"&gt;in&lt;/span&gt; freeProductsCategory.Products) {
    dsc.DeleteLink(freeProductsCategory, &lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, freeProduct);
}
&lt;span class="rem"&gt;//Delete the parent entity&lt;/span&gt;
dsc.DeleteObject(freeProductsCategory);
dsc.SaveChanges();&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Wait !! what’s with the LoadProperty there ? 
    &lt;br /&gt;&lt;/strong&gt;Well, if you need to delete the relation , the way to identify the relation or the link is to have both the right and the left end of the relations to be materialized. without the expand , the Contact and the Customer property are null , and we don’t know which relation to delete.In case of 1..1 relations it might be easy to predict based on the relation name , 

  &lt;br /&gt;but wouldn’t be easy in case of 1..n relations. 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deleting the child entity&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;&lt;span class="rem"&gt;//Load an existing parent&lt;/span&gt;
Categories freeProductsCategory = dsc
                                   .CreateQuery&amp;lt;Categories&amp;gt;(&lt;span class="str"&gt;&amp;quot;Categories&amp;quot;&lt;/span&gt;)
                                   .Where(cat =&amp;gt; cat.CategoryName == &lt;span class="str"&gt;&amp;quot;Free Products&amp;quot;&lt;/span&gt;)
                                   .First();
&lt;span class="rem"&gt;//Load all the related child Entities&lt;/span&gt;
dsc.LoadProperty(freeProductsCategory, &lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;);

&lt;span class="rem"&gt;//Delete the links with each of the child entities&lt;/span&gt;
&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Products freeProduct &lt;span class="kwrd"&gt;in&lt;/span&gt; freeProductsCategory.Products) {
    dsc.DeleteLink(freeProductsCategory, &lt;span class="str"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;, freeProduct);
&lt;span class="rem"&gt;    //Delete the child entity&lt;/span&gt;
    dsc.DeleteObject(freeProduct);
}
dsc.SaveChanges();&lt;/pre&gt;

&lt;h5&gt;Special Consideration for Navigation properties that are named differently than the Entity Type&lt;/h5&gt;

&lt;p&gt;This is a special case because of a bug in the client library at the time of writing this post. 
  &lt;br /&gt;If you have a navigation property&amp;#160; which is named differently than the EntityType and try to delete the link between the source 

  &lt;br /&gt;and the navigation property , we produce an invalid URI for the DELETE of the link. 

  &lt;br /&gt;

  &lt;br /&gt;ex: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Entity Type :&lt;/strong&gt; Customers , &lt;strong&gt;EntitySet Name : &lt;/strong&gt;Customers 

  &lt;br /&gt;&lt;strong&gt;Navigation Properties : 
    &lt;br /&gt;&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;EntityType :&lt;/strong&gt; Orders , &lt;strong&gt;Navigation Property Name :&lt;/strong&gt; CashOrders 

  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;EntityType : &lt;/strong&gt;Orders , &lt;strong&gt;Navigation Property Name : &lt;/strong&gt;CreditCardOrders 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;br /&gt;Upon calling , 

  &lt;br /&gt;dataContext.DeleteLink(customerInstance,”CashOrders”,orderInstance); 

  &lt;br /&gt;

  &lt;br /&gt;We generate a DELETE to the URI 

  &lt;br /&gt;/Customers(Key)/$links/Orders(Key) 

  &lt;br /&gt;This is wrong , the DELETE should go to : 

  &lt;br /&gt;/Customers(Key)/$links/CashOrders(Key) 

  &lt;br /&gt;

  &lt;br /&gt;We will address this issue in a future release .In the meantime ,&amp;#160; use the workaround below , &lt;/p&gt;

&lt;pre class="darkcsharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; YourDataContextClass {

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DeleteLinkManual(&lt;span class="kwrd"&gt;object&lt;/span&gt; source, &lt;span class="kwrd"&gt;string&lt;/span&gt; associationName, &lt;span class="kwrd"&gt;object&lt;/span&gt; target) {
            System.Uri UriOfParent;
            System.Uri UriOfChild;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.TryGetUri(source, &lt;span class="kwrd"&gt;out&lt;/span&gt; UriOfParent);
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.TryGetUri(target, &lt;span class="kwrd"&gt;out&lt;/span&gt; UriOfChild);

            &lt;span class="rem"&gt;//Get the Segment of the URI with the Key &lt;/span&gt;
            &lt;span class="kwrd"&gt;string&lt;/span&gt; strChildAssociationURI = UriOfChild.Segments.Last();
            strChildAssociationURI = strChildAssociationURI.Substring(strChildAssociationURI.IndexOf(&lt;span class="str"&gt;'('&lt;/span&gt;));

            &lt;span class="rem"&gt;//ServiceEndPoint/ParentEntitySet/$links/NavigationPropertyName(ChildEntitySetKey)&lt;/span&gt;
            &lt;span class="kwrd"&gt;string&lt;/span&gt; requestUriForLinkDelete = System.String.Format(&lt;span class="str"&gt;&amp;quot;{0}/{1}/$links/{2}{3}&amp;quot;&lt;/span&gt;,
                                             &lt;span class="kwrd"&gt;this&lt;/span&gt;.BaseUri.OriginalString,
                                             UriOfParent.Segments.Last(),
                                             associationName,
                                             strChildAssociationURI);

            System.Net.WebRequest request = System.Net.WebRequest.Create(requestUriForLinkDelete);
            request.Method = &lt;span class="str"&gt;&amp;quot;DELETE&amp;quot;&lt;/span&gt;;
            System.Net.HttpWebResponse response = request.GetResponse() &lt;span class="kwrd"&gt;as&lt;/span&gt; System.Net.HttpWebResponse;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (response.StatusCode != System.Net.HttpStatusCode.NoContent)
            {
                &lt;span class="kwrd"&gt;throw&lt;/span&gt; (&lt;span class="kwrd"&gt;new&lt;/span&gt; System.Data.Services.Client.DataServiceClientException(&lt;span class="str"&gt;&amp;quot;Delete Failed&amp;quot;&lt;/span&gt;));
            }
            &lt;span class="rem"&gt;//Detach this link as the link no longer exists and keep the context consistent&lt;/span&gt;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.DetachLink(source, associationName, target);
      }
}&lt;/pre&gt;

&lt;p&gt;and then , in your code , &lt;/p&gt;

&lt;br /&gt;

&lt;pre class="darkcsharpcode"&gt;YourDataContext dataContext = new YourDataContext(&amp;lt;Uri&amp;gt;);&lt;br /&gt;dataContext.DeleteLinkManual(customerInstance,”CashOrders”,orderInstance);&lt;/pre&gt;

&lt;p&gt;This will produce the right URI : &lt;/p&gt;

&lt;br /&gt;

&lt;pre class="darkcsharpcode"&gt;ServiceEndPoint/Customers(Key)/$links/CashOrders(Key) &lt;/pre&gt;

&lt;p&gt;Note that this doesnt work in Silverlight , I will create a separate sample for Silverlight later . 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;If you have any questions&amp;#160; , leave a comment . If you have any issues with code and need help , please post your query on the astoria forums as I can’t promise that I will be able to reply to emails sent to me directly .The whole team is very active on the forums and the more eyes on a problem the better. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9013687" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/DataServiceContext/default.aspx">DataServiceContext</category></item><item><title>Accessing Cross-Domain ADO.NET Data Services from the Silverlight Client Library</title><link>http://blogs.msdn.com/phaniraj/archive/2008/10/21/accessing-cross-domain-ado-net-data-services-from-the-silverlight-client-library.aspx</link><pubDate>Tue, 21 Oct 2008 05:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9008548</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9008548.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9008548</wfw:commentRss><description>&lt;p&gt;When we built the client library for Silverlight in Silverlight 2.0 , the underlying Network Stack provided by Silverlight core libraries    &lt;br /&gt;was very limited in terms of the Status Codes and Request Verbs that it supported.Our options were :     &lt;br /&gt;a) Use the System.Net libraries provided by the agClr and give a limited subset of the functionality available on the desktop.     &lt;br /&gt;b) Cook up our own Network stack and provide all the functionality provided on the desktop , in Silverlight.&lt;/p&gt;  &lt;p&gt;We went with Option (b) and built a network stack that uses the browser’s underlying XmlHttpRequest object.    &lt;br /&gt;This means that the &lt;a href="http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx"&gt;cross domain access available in Silverlight networking stack&lt;/a&gt; is not available in our networking stack.     &lt;br /&gt;    &lt;br /&gt;Forums user Ben Hayat asked a &lt;a href="http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=3995200&amp;amp;SiteID=1"&gt;question&lt;/a&gt; about the guidelines for Cross-Domain access using our Silverlight Client Library .     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Now , this is not supported out of the box . But ,you can use the same solution as you would for an Ajax application ,    &lt;br /&gt;which is building&amp;#160; a server-side proxy that talks to the remote service and is completely transparent to the client library.     &lt;br /&gt;    &lt;br /&gt;Below is a sample Server-Side proxy that would help one talk to Data Services hosted on a different domain than the Silverlight application.     &lt;br /&gt;    &lt;br /&gt;There are a couple of issues that a Server-Side proxy needs to solve for an ADO.NET Data Service ,     &lt;br /&gt;&amp;#160; a) Appear totally transparent     &lt;br /&gt;&amp;#160; b) Resolve Identities of resources to appear as they would from the Proxy service and not the original Data Service.     &lt;br /&gt;    &lt;br /&gt;Issue a) is easy , Issue b) is a little more involved.     &lt;br /&gt;    &lt;br /&gt;When the client library receives a Payload back as part of a query ,we construct the entity’s identity based on the following rules,     &lt;br /&gt;ex: If you browse to &lt;a href="http://ServiceEndpoint/Northwind.svc/"&gt;&lt;strong&gt;http://ServiceEndpoint&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;/Northwind.svc/Customers('ALFKI') ,&lt;/strong&gt;the response looks like this :&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&amp;#160;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;entry&lt;/span&gt; &lt;strong&gt;&lt;font color="#800040"&gt;&lt;span class="attr"&gt;xml:base&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://ServiceEndpointNorthwind.svc/&amp;quot;&lt;/span&gt; 
&lt;/font&gt;&lt;/strong&gt;       &lt;span class="attr"&gt;xmlns:d&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices&amp;quot;&lt;/span&gt; 
       &lt;span class="attr"&gt;xmlns:m&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/ado/2007/08/dataservices/metadata&amp;quot;&lt;/span&gt; 
       &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://www.w3.org/2005/Atom&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;strong&gt;&lt;font color="#800000"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;link&lt;/span&gt; &lt;span class="attr"&gt;rel&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;edit&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Customers&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Customers('ALFKI')&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; 
&lt;/font&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;http://ServiceEndpointNorthwind.svc/Customers('ALFKI')&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/strong&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;content&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;application/xml&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;m:properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
     &lt;strong&gt;Properties go here &lt;br /&gt;&lt;/strong&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;m:properties&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;entry&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;When we get the above payload back as a response , we&amp;#160; create&amp;#160; a Customer object and its identity is the value of the &amp;lt;id&amp;gt; field in the payload. 
  &lt;br /&gt;When you make any edits to this Customer object, &lt;u&gt;the edits are sent to the URI specified in the &amp;lt;link rel=”edit”&amp;gt; value of the payload. 
    &lt;br /&gt;&lt;/u&gt;Which means that the proxy server has to modify the payload it recieves from the real Data Service to make sure that all links , Id and Edit 

  &lt;br /&gt;point to the proxy Data Service and not the real Data Service. The easiest way to do this is to do a String.Replace replacing all occurrences of the 

  &lt;br /&gt;the original Service end point with the Proxy Service end point in the payload.&lt;/p&gt;

&lt;p&gt;Without further stalling&amp;#160; , here is the&amp;#160; &lt;a href="http://blogs.msdn.com/phaniraj/attachment/9008548.ashx"&gt;Proxy Handler&lt;/a&gt;. &lt;/p&gt;

&lt;h5&gt;A couple of words of caution so that I can keep my job, &lt;/h5&gt;

&lt;ol&gt;
  &lt;li&gt;This is only a sample implementation of what a proxy &lt;strong&gt;could&lt;/strong&gt;&lt;em&gt;&lt;/em&gt; look like. &lt;/li&gt;

  &lt;li&gt;Do &lt;strong&gt;NOT&lt;/strong&gt; use this in your production applications. &lt;/li&gt;

  &lt;li&gt;This is &lt;strong&gt;NOT&lt;/strong&gt; an official solution provided by the ADO.NET Data Services team , 

    &lt;br /&gt;this is just me illustrating how to write a proxy. &lt;/li&gt;

  &lt;li&gt;If you download this sample , it means that you understand these rules . &lt;/li&gt;

  &lt;li&gt;For any problems with this sample , leave a comment on my blog , 
    &lt;br /&gt;the ADO.NET Data Services Forums is &lt;strong&gt;NOT &lt;/strong&gt;the right place for any issues with this proxy. &lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;Running the sample&amp;#160; &lt;/h5&gt;

&lt;ol&gt;
  &lt;li&gt;Download the sources from the link above. &lt;/li&gt;

  &lt;li&gt;Open the solution in Visual Studio 2008 and hit F5. &lt;/li&gt;

  &lt;li&gt;You should see the Silverlight application come up and 
    &lt;br /&gt;get the data from the Data Service hosted in a different application. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Cross Domain Proxy is a generic AShx handler which receives the requests from the Client library and forwards them onto the 
  &lt;br /&gt;original Data Service , gets the response , changes the ID and Edit Links and returns the response to the Silverlight Client . &lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Client Sends request to Proxy Handler &lt;/li&gt;

  &lt;li&gt;Proxy Handler sends the request data to the Original Data Service &lt;/li&gt;

  &lt;li&gt;Data Service responds with response &lt;/li&gt;

  &lt;li&gt;Proxy handler reads response and changes the ID and EDIT links in the payload &lt;/li&gt;

  &lt;li&gt;In case of POST , the Proxy Handler changes the response “Location” Header 
    &lt;br /&gt;so that the identity points to the Proxy Handler and not the Data Service. &lt;/li&gt;

  &lt;li&gt;Proxy handler returns the response data to the client . &lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;How do I use this in my application ?&lt;/h5&gt;

&lt;br /&gt;

&lt;p&gt;The source available for download contains “CrossDomainHandlerBase” which is the class that contains the functionality required 
  &lt;br /&gt;for recieving requests from clients and forwarding the requests onto the Data Service. &lt;/p&gt;

&lt;h5&gt;Setting up the Server-Side Proxy &lt;/h5&gt;

&lt;br /&gt;

&lt;ol&gt;
  &lt;li&gt;Add a Generic ASHX Handler to the application that contains the Web page hosting the Silverlight application , 
    &lt;ol&gt;
      &lt;li&gt;Right-Click on Project &lt;/li&gt;

      &lt;li&gt;Add –&amp;gt; New Item –&amp;gt; Generic Handler 
        &lt;br /&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/AccessingCrossDomainDataServicesfromtheS_C375/image_2.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="449" alt="image" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/AccessingCrossDomainDataServicesfromtheS_C375/image_thumb.png" width="644" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 2. This will create a Generic Handler which implements IHttpHandler.&lt;/p&gt;

&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 3. Remove the code stubs for IHttpHandler methods and properties . 
  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; 4. Replace IHttpHandler with “CrossDomainHandlerBase”.&amp;#160; &lt;br /&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;    [WebService(Namespace = &lt;span class="str"&gt;&amp;quot;http://tempuri.org/&amp;quot;&lt;/span&gt;)]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CrossDomainHandler : CrossDomainHandlerBase
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; CrossDomainHandler()
            : &lt;span class="kwrd"&gt;base&lt;/span&gt;()
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.DataServiceURI = &lt;span class="str"&gt;&amp;quot;URI FOR THE DATA SERVICE&amp;quot;&lt;/span&gt;;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.ProxyServiceURI = &lt;span class="str"&gt;&amp;quot;URI FOR THE PROXY SERVICE&amp;quot;&lt;/span&gt;;
        }
     }&lt;/pre&gt;

&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; 4.From this point on , for all purposes , the Proxy Handler service IS the Data Service&lt;/p&gt;

&lt;h5&gt;Setting up the Silverlight application for Cross-Domain access&lt;/h5&gt;

&lt;ol&gt;
  &lt;li&gt;Right-Click on “References” in the Project &lt;/li&gt;

  &lt;li&gt;Select &amp;quot;Add Service Reference&amp;quot; &lt;/li&gt;

  &lt;li&gt;In the “Address” field , enter the URI for the proxy service , &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/AccessingCrossDomainDataServicesfromtheS_C375/image_6.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="image" src="http://blogs.msdn.com/blogfiles/phaniraj/WindowsLiveWriter/AccessingCrossDomainDataServicesfromtheS_C375/image_thumb_2.png" width="519" border="0" /&gt;&lt;/a&gt; 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;In case of the sample solution provided, the Provider is called “DataProvider”, hence 
    &lt;br /&gt;the code-gen produces the code with a type “DataProvider” derived from DataServiceContext. &lt;/li&gt;

  &lt;li&gt;When you instantiate the Context in the Silverlight application , always specify the Base URI 
    &lt;br /&gt;as the Proxy Handler’s URI, 

    &lt;br /&gt;

    &lt;pre class="csharpcode"&gt;DataProvider dataProvider = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataProvider(
                &lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;&amp;quot;RELATIVE URI FOR THE PROXY SERVICE&amp;quot;&lt;/span&gt;, 
                            UriKind.RelativeOrAbsolute)
                  );&lt;/pre&gt;
  &lt;/li&gt;

  &lt;li&gt;This is the most important step of all &lt;strong&gt;, Party on !!&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To do in the near future :&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Convert the Handler to be an IHttpAsyncHandler so that we dont block on waiting for the response from the Data Service &lt;/li&gt;

  &lt;li&gt;Provide better mechanisms for Identity Resolution other than String.Replace . &lt;/li&gt;

  &lt;li&gt;Write a better demo app than something which binds all the parts of my name to a Grid. &lt;/li&gt;

  &lt;li&gt;Your suggestion goes here . &lt;/li&gt;
&lt;/ol&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9008548" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/phaniraj/attachment/9008548.ashx" length="2976444" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Prototype/default.aspx">Prototype</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/CrossDomain/default.aspx">CrossDomain</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Demo/default.aspx">Demo</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/DataServiceContext/default.aspx">DataServiceContext</category></item><item><title>Viewer Mail , #1</title><link>http://blogs.msdn.com/phaniraj/archive/2008/10/16/viewer-mail-1.aspx</link><pubDate>Thu, 16 Oct 2008 08:55:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9001480</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/9001480.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=9001480</wfw:commentRss><description>&lt;p&gt;&lt;em&gt;Disclaimer&amp;#160; : These are my thoughts and opinions , although I work on the Astoria team , I am not the voice of the team.The team has its own voice and can be heard here : &lt;/em&gt;&lt;a target="_blank" href="http://blogs.msdn.com/astoriateam/"&gt;&lt;em&gt;Project Astoria Team Blog&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Hola ! &lt;/p&gt;  &lt;p&gt;I am interrupting my regularly scheduled blog post to&amp;#160; answer some really interesting questions about one of my blog posts , i.e &lt;a target="_blank" href="http://blogs.msdn.com/phaniraj/archive/2008/07/02/working-with-relations-in-ado-net-data-services-beta-1.aspx" rel="nofollow"&gt;Working with Associations in ADO.NET Data Services&lt;/a&gt;.&amp;#160; These questions are from the comments on the post and     &lt;br /&gt;also the public forums.     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Vince says :      &lt;br /&gt;&lt;/strong&gt;”Hi,&lt;/p&gt;  &lt;p&gt;I find bad to be forced to use the Addlink to allow us to save relational object in the DB.&lt;/p&gt;  &lt;p&gt;We have a pretty full object model but the Addlink method needs string argument. As each entity knows all navigation properties, why to not have something like entity.NavigationObject rather than string SourceProperty. At least, myObject.MyNavigationProperty.Name or ToStringName would be better. &lt;/p&gt;  &lt;p&gt;Thanks&lt;/p&gt;  &lt;p&gt;Nice blogs&lt;/p&gt;  &lt;p&gt;Regards&lt;/p&gt;  &lt;p&gt;-Vince”&lt;/p&gt;  &lt;p&gt;e    &lt;br /&gt;Thank you Vince for the compliment and let me try to explain the reason we built the client this way.     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;For V1 , we wanted to give you POCO access to the data classes. Although we could infer the relation based on the type of the navigation property , this would break scenarios where we have more than 1 navigation properties of the same type and belonging to the same entity Set.&lt;/p&gt;  &lt;p&gt;Consider this entity ,&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Customer {
&lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;Orders&amp;gt; CashPurchases{get;set;}
&lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;Orders&amp;gt; CreditCardPurchases{get;set;}
 }&lt;/pre&gt;

&lt;p&gt;If you do an AddLink with just an instance of Orders, we would have to guess which navigation property we have to add the link to .&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Customer newCustomer = &lt;span class="kwrd"&gt;new&lt;/span&gt; Customer();
Orders cashPurchase = &lt;span class="kwrd"&gt;new&lt;/span&gt; Orders();
Orders creditCardPurchase = &lt;span class="kwrd"&gt;new&lt;/span&gt; Orders();
context.AddLink( newCustomer , &lt;span class="str"&gt;&amp;quot;&lt;strong&gt;??&lt;/strong&gt;&amp;quot;&lt;/span&gt;, cashPurchase);&lt;/pre&gt;

&lt;p&gt;In the above case , trying to guess the name of the association will land us in hot water as we &lt;strong&gt;don't know which navigation property you intended &lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;we cant go the other way around and try to use the instance of Orders to guess the name of the association 
  &lt;br /&gt;as we Orders may have other associations of type Customers and we dont know which one you intended. 

  &lt;br /&gt;If you do not wish to use the string to remember the association name , you can move that to a separate resource file and have all your strings localized in one place.&lt;/p&gt;

&lt;p&gt;Consider this ..&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; StoreConstants{
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Customers_To_CashPurchases  =&lt;span class="str"&gt;&amp;quot;CashPurchases&amp;quot;&lt;/span&gt;;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Customers_To_CreditCardPurchases  =&lt;span class="str"&gt;&amp;quot;CreditCardPurchases&amp;quot;&lt;/span&gt;;
}&lt;/pre&gt;

&lt;p&gt;and then in your code ,&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Customer newCustomer = &lt;span class="kwrd"&gt;new&lt;/span&gt; Customer();
Orders cashPurchase = &lt;span class="kwrd"&gt;new&lt;/span&gt; Orders();
Orders creditCardPurchase = &lt;span class="kwrd"&gt;new&lt;/span&gt; Orders();
context.AddLink( newCustomer , StoreConstants.Customers_To_CashPurchases , cashPurchase);
context.AddLink( newCustomer , StoreConstants.Customers_To_CreditCardPurchases , creditCardPurchase);&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Simon says : 
    &lt;br /&gt;&lt;/strong&gt;

  &lt;br /&gt;”Hi Phani,&lt;/p&gt;

&lt;p&gt;Nice clear exposition of the topic.&lt;/p&gt;

&lt;p&gt;However, I would think that, given that we are working with a client-side proxy, the separation of object tracking and association tracking is a bit too abstract for the most common scenarios where this client class may be used, ie with out-of-the-box databinding to UI components etc.&lt;/p&gt;

&lt;p&gt;I understand the nice separation of concerns etc, but surely if the Customer or Contact properties are set in code, the user intends them to be set.I guess it is about user intentions and usability. Could you provide an overload such as &lt;/p&gt;

&lt;p&gt;Context.AddObject( String property,Object value, Boolean shouldTrackAssociations) 
  &lt;br /&gt;

  &lt;br /&gt;Just a thought/suggestion. 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Cheers, 
  &lt;br /&gt;Simon” 

  &lt;br /&gt;

  &lt;br /&gt;Thanks Simon for the compliment and lets explore this further, 

  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;I agree that the concept of treating associations as first class resources is somewhat new to the application scenarios where the client library is being used.&lt;/p&gt;

&lt;p&gt;At the same time , we dont want to make assumptions on how the relation exists on the server as the client does not have enough information about the server schema. &lt;/p&gt;

&lt;p&gt;Sure , we have the CLR types reflect the associations on the server i.e Reference for 1..1 relations and Collection types for 1..N relations.&lt;/p&gt;

&lt;p&gt;But we really dont want to make assumptions about this.&lt;/p&gt;

&lt;p&gt;Associations are first class resources on the server too , which means that any changes to associations should happen as separate requests or as part of another request. That making the assumption of a given relation causes an additional HTTP Request&amp;#160; , which uses bandwidth you will be paying for .&lt;/p&gt;

&lt;p&gt;Even if we added some magic to cause &lt;/p&gt;

&lt;p&gt;newProduct.Categories.Add(newCategory) ;&lt;/p&gt;

&lt;p&gt;to be &lt;/p&gt;

&lt;p&gt;Context.AddLink(newProduct,&amp;quot;Categories&amp;quot;,newCategory);&lt;/p&gt;

&lt;p&gt;then the entity classes Products and Category would have to know about the DataServiceContext ,&lt;/p&gt;

&lt;p&gt;newProduct.Context = myDataServiceContext;&lt;/p&gt;

&lt;p&gt;and this would just look ugly&amp;#160; ,IMHO. 
  &lt;br /&gt;

  &lt;br /&gt;Now , that was just me explaining how things are and why we cant do this &lt;strong&gt;&lt;em&gt;today &lt;/em&gt;&lt;/strong&gt;. 

  &lt;br /&gt;

  &lt;br /&gt;Let me share my thoughts of how this should be done and see how this sits with you . 

  &lt;br /&gt;If an entity has only one navigation property of a specify type . 

  &lt;br /&gt;&lt;em&gt;ex: Customers has only one Navigation property of type Address. 
    &lt;br /&gt;&lt;/em&gt;Regardless of whether it is a Reference property or a Collection property, 

  &lt;br /&gt;updating the CLR property on the entity should setup the link 

  &lt;br /&gt;

  &lt;br /&gt;ex: 

  &lt;br /&gt;Address newAddress = new Address(){ 

  &lt;br /&gt;City=’Bellevue’, 

  &lt;br /&gt;State=’WA’ 

  &lt;br /&gt;};&lt;/p&gt;

&lt;p&gt;newCustomer.Address = newAddress; 
  &lt;br /&gt;

  &lt;br /&gt;should automatically set this relation up in this way , 

  &lt;br /&gt;

  &lt;br /&gt;context.SetLink(newCustomer,”Address”,newAddress); 

  &lt;br /&gt;

  &lt;br /&gt;To achieve this ,&lt;em&gt; without letting the entities know about the context &lt;/em&gt;,the entities would have to notify the context that they have navigation properties and the context should listen for changes to the navigation properties. 

  &lt;br /&gt;But when should the context hook itself up to the afore-mentioned events ? 

  &lt;br /&gt;when the source entity is modified in some way perhaps ? 

  &lt;br /&gt;

  &lt;br /&gt;ex : &lt;/p&gt;

&lt;pre class="csharpcode"&gt;context.AddObject(“Customers”,newCustomer);&lt;br /&gt;
//pseudo code &lt;span class="kwrd"&gt;for&lt;/span&gt; AddObject&lt;br /&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddObject(&lt;span class="kwrd"&gt;string&lt;/span&gt; entitySetName,&lt;span class="kwrd"&gt;object&lt;/span&gt; entity) {
   ICanHazNavigationProperties navProps = entity &lt;span class="kwrd"&gt;as&lt;/span&gt; ICanHazNavigationProperties ;
    &lt;span class="kwrd"&gt;if&lt;/span&gt;( navProps !=&lt;span class="kwrd"&gt;null&lt;/span&gt;) {
    navProps.RegisterHandler(HandleNavPropChange);
  }&lt;br /&gt;// do something here 
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; HandleNavPropChange(&lt;span class="kwrd"&gt;object&lt;/span&gt; source,&lt;span class="kwrd"&gt;string&lt;/span&gt; associationName,&lt;br /&gt;               &lt;span class="kwrd"&gt;object&lt;/span&gt; target,Multiplicity associationMultiplicity,NavPropAction action) &lt;br /&gt;{
&lt;span class="kwrd"&gt;  switch&lt;/span&gt;(action)
  {
    &lt;span class="kwrd"&gt;case&lt;/span&gt; ( NavPropAction.AddLink ) :
                &lt;span class="kwrd"&gt;switch&lt;/span&gt;(associationMultiplicity) {
                         &lt;span class="kwrd"&gt;case&lt;/span&gt; Multiplicity.One :
                           &lt;span class="kwrd"&gt;this&lt;/span&gt;.SetLink(source,associationName,target);
                          &lt;span class="kwrd"&gt;break&lt;/span&gt;;
               }
    &lt;span class="kwrd"&gt;break&lt;/span&gt;;      &lt;br /&gt; //Other cases skipped for brevity  
    }
  }
  
}&lt;/pre&gt;

&lt;p&gt;Now , if we go with this approach, the entity types themselves cannot be pure POCO objects if you want automatic 
  &lt;br /&gt;link tracking.&amp;#160; For auto generated types using DataSvcUtil.exe or “Add Service Reference” this is no big deal. 

  &lt;br /&gt;But what about cases where one has to &lt;strong&gt;hand-craft the entity types by hand ?&lt;/strong&gt; 

  &lt;br /&gt;

  &lt;br /&gt;Well, this was me just thinking out loud. If you agree/disagree , leave a comment and get featured in the next 

  &lt;br /&gt;“Viewer Mail”. 

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;A data geek joke , just like associations are first class resources , comments are first class material for blog posts :)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9001480" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Viewer+Mail/default.aspx">Viewer Mail</category></item><item><title>Astoria &amp; IIS , HTTP 400 Bad Request on Posting Large Payloads to an astoria service</title><link>http://blogs.msdn.com/phaniraj/archive/2008/10/06/astoria-iis-http-400-bad-request-on-posting-large-payloads-to-an-astoria-service.aspx</link><pubDate>Mon, 06 Oct 2008 05:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8977408</guid><dc:creator>PhaniRajuYN</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/phaniraj/comments/8977408.aspx</comments><wfw:commentRss>http://blogs.msdn.com/phaniraj/commentrss.aspx?PostID=8977408</wfw:commentRss><description>&lt;P&gt;We’ve seen this in the labs and also reported by our customers on the forums, If you try to post&amp;nbsp; a large amount of data to &lt;BR&gt;an astoria data service , you might receive a response code Http 400 Bad Request even though the response data is valid. &lt;BR&gt;&lt;BR&gt;An ADO.NET Data Service sits on top of Windows Communication Foundation , although most of the required plumbing is hidden away from you&amp;nbsp; ,&amp;nbsp; you can still see the effects in scenarios such as this .&lt;/P&gt;
&lt;H6&gt;Why do I get a generic 400 Bad Request in this case ?&lt;/H6&gt;When the request size ( including headers ) exceeds 64 K ( 65536 bytes ) , WCF chokes on the request as this request size is greater than the limit on the maximum size of the request the service can recieve and sends out a HTTP 400 Bad Request as the request is invalid. &lt;BR&gt;&lt;BR&gt;
&lt;H6&gt;How do I fix this ?&lt;/H6&gt;
&lt;P&gt;a)The maximum size of the request which a WCF service can process is controlled by the &lt;A href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.transportbindingelement.maxreceivedmessagesize.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.transportbindingelement.maxreceivedmessagesize.aspx"&gt;MaxReceivedMessageSize&lt;/A&gt; property on the WCF binding. &lt;BR&gt;The default value is 65536 ,exceeding which you get the 400 response code. &lt;BR&gt;&lt;BR&gt;In the web.config of the web site hosting the service , add the following node in the &amp;lt;System.ServiceModel&amp;gt; section. &lt;/P&gt;&lt;BR&gt;&lt;PRE class=darkcsharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.serviceModel&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;services&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
  &lt;SPAN class=rem&gt;&amp;lt;!-- The name of the service --&amp;gt;&lt;/SPAN&gt; 
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;service&lt;/SPAN&gt; &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="NorthwindService"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
    &lt;SPAN class=rem&gt;&amp;lt;!-- you can leave the address blank or specify your end point URI --&amp;gt;&lt;/SPAN&gt; 
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;endpoint&lt;/SPAN&gt; &lt;SPAN class=attr&gt;address&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;="YourServiceEndpoint"&lt;/SPAN&gt; 
              &lt;SPAN class=attr&gt;binding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="webHttpBinding"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;bindingConfiguration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="higherMessageSize"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;contract&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;="System.Data.Services.IRequestHandler"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;endpoint&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;service&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;services&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;bindings&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;webHttpBinding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
    &lt;SPAN class=rem&gt;&amp;lt;!-- configure the maxReceivedMessageSize  value to suit the max size of &lt;/SPAN&gt;
&lt;SPAN class=rem&gt;         the request ( in bytes ) you want the service to recieve--&amp;gt;&lt;/SPAN&gt; 
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;binding&lt;/SPAN&gt; &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="higherMessageSize"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;maxReceivedMessageSize&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;="MaxMessageSize"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt; 
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;webHttpBinding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;bindings&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;serviceHostingEnvironment&lt;/SPAN&gt; &lt;SPAN class=attr&gt;aspNetCompatibilityEnabled&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="true"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.serviceModel&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;b) If hosted on IIS , the ASP.Net Request Size restriction can also cause a large request to be rejected, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You will need to set the &lt;A href="http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx"&gt;HttpRuntimeSection.MaxRequestLength&lt;/A&gt; Property. &lt;/P&gt;&lt;PRE class=darkcsharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;httpRuntime&lt;/SPAN&gt; &lt;SPAN class=attr&gt;MaxRequestLength&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="ValueInKiloBytes"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;H6&gt;How do I Identify if the reason I am seeing a 400 Bad Request&amp;nbsp; is because of the request size ?&lt;/H6&gt;
&lt;P&gt;Identify if WCF is throwing an exception under the covers which is not being surfaced to you at the HTTP level. &lt;BR&gt;You can &lt;A title="Instructions on configuring WCF tracing" href="http://msdn.microsoft.com/en-us/library/ms733025.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms733025.aspx"&gt;configure WCF tracing&lt;/A&gt; on the server-side to log the necessary information from the WCF layer. &lt;BR&gt;Once you have tracing setup and you reproduced the failure , check if the log contains one or both of these exception messages.&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;PRE class=darkcsharpcode&gt;System.ServiceModel.ProtocolException
&lt;SPAN class=str&gt;"The maximum message size quota for incoming messages (65536) has been exceeded. 
To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."
&lt;/SPAN&gt;
System.Web.HttpException
&lt;SPAN class=str&gt;"Maximum request length exceeded."&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;If you see that the log does contain this message , then you can be sure that the failure is because of the message size &lt;BR&gt;and apply this fix accordingly.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8977408" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Astoria/default.aspx">Astoria</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://blogs.msdn.com/phaniraj/archive/tags/IIS/default.aspx">IIS</category></item></channel></rss>