<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Benjamin Devuyst &#187; Silverlight</title>
	<atom:link href="https://blog.developpez.com/bdevuyst/pcategory/dotnet-net/silverlight/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/bdevuyst</link>
	<description>:)</description>
	<lastBuildDate>Mon, 16 Mar 2020 06:57:16 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>WCF RIA Services et les Query &#171;&#160;maison&#160;&#187;, ou comment implémenter des query complexes</title>
		<link>https://blog.developpez.com/bdevuyst/p8703/dotnet-net/silverlight/wcf_ria_services_query_complexes</link>
		<comments>https://blog.developpez.com/bdevuyst/p8703/dotnet-net/silverlight/wcf_ria_services_query_complexes#comments</comments>
		<pubDate>Mon, 08 Mar 2010 15:05:53 +0000</pubDate>
		<dc:creator><![CDATA[benji_dv]]></dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WCF Ria Services]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Bonjour à vous ! Un petit post mignon tout plein aujourd&#8217;hui. WCF RIA Services nous permet de requêter, de façon quasi transparente, une source de données depuis une application cliente Silverlight (par exemple). La syntaxe utilisée consiste à appeler Load de l&#8217;objet DomainContext instancié et de lui préciser quelle query utiliser. Ce mécanisme suffit largement pour des filtrages basiques. Lorsque l&#8217;on a à utiliser des filtrage plus complexes, RIA se trouve vite à bout de [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Bonjour à vous ! Un petit post mignon tout plein aujourd&rsquo;hui. </p>
<p>WCF RIA Services nous permet de requêter, de façon quasi transparente, une source de données depuis une application cliente Silverlight (par exemple). </p>
<p>La syntaxe utilisée consiste à appeler Load de l&rsquo;objet DomainContext instancié et de lui préciser quelle query utiliser. </p>
<p>Ce mécanisme suffit largement pour des filtrages basiques. </p>
<p>Lorsque l&rsquo;on a à utiliser des filtrage plus complexes, RIA se trouve vite à bout de souffle.</p>
<p>Pour les exemples ci dessous, nous considérons que nous disposons du modèle de données suivant (Entity Framework par exemple) :<br />
Une voiture contient 0-n roues,<br />
Les roues ne sont pas retournées par défaut avec les voitures sur le client (via RIA).
</p>
<p>
Exemple de situation complexe : </p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> var monDomainCtx = <span style="color: #0000ff">new</span> VehiculeDomainSrv();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> var query = monDomainCtx.GetVoitureQuery().Where(</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     voiture =&gt; voiture.Roues.Any(roue=&gt;roue.IsAPlat));</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> monDomainCtx.Load&lt;Voiture&gt;(</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     query,</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     loadOp=&gt;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         ... <span style="color: #008000">// opération de chargement des voitures à pneu plat</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>     },</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>     <span style="color: #0000ff">false</span>);</pre>
</p></div>
</div>
<p>Nous tentons ici (côté client), de demander à RIA d’aller rechercher toutes les voiture qui ont (au moins) un pneu crevé (sous requête).<br />
  <br />Dans ce cas de figure (présence d’une ou plusieurs sous requête), RIA va nous renvoyer une exception dont le message parlera d’une impossibilité d’utiliser Any (mais ce serait la même chose pour Count, First, etc).</p>
<p><b>La solution : </b></p>
<p>Dans le DomainServices (donc sur le serveur), nous allons implémenter une méthode décorée de l’attribut &laquo;&nbsp;System.Web.DomainServices.QueryAttribute&nbsp;&raquo;. Nous implémentons donc nos propres query !</p>
<p>Cette méthode retournera donc un objet IQueryable (au même titre que celles fournies par défaut : GetVoitureQuery() )</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [Query()]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> IQueryable&lt;Voiture&gt; GetFiltreVoitures(Boolean roueCrevee)</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     <span style="color: #008000">// création de la query de base retournéà partir du DataModel</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     var dataCtx = <span style="color: #0000ff">new</span> GarageLocationDataModel();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     <span style="color: #0000ff">return</span> dataCtx.Voiture.Where(voit =&gt; voit.Roue.Any(roue =&gt; roue.IsAPlat));</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> }</pre>
</p></div>
</div>
<p>Lors de l’exécution, nous utiliserons le code suivant (côté client)</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> var dataCtx = <span style="color: #0000ff">new</span> VehiculeDomainSrv();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> dataCtx.Load&lt;Vehicule&gt;(</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     dataCtx.GetFiltreVoiture(true),</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     loadOp=&gt;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>         <span style="color: #008000">// Corps de méthode pour récupérer les résultats</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         ...</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>     },</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>     <span style="color: #0000ff">false</span>);</pre>
</p></div>
</div>
<p>Le client ne fait que demander l&rsquo;exécution de la query, cette dernière sera bien entendu exécutée (physiquement) sur le serveur.</p>
<p>Petite précision sur les méthodes Query :</p>
<p>Il faut noter une petite restriction concernant les paramètres des query : il n’est pas possible (à ce jour) de passer en paramètre un objet d’un type qui encapsule tous les critères de recherche (exemple : CritereVehicule).</p>
<p>En effet, les seuls types autorisés par RIA comme paramètre de query sont les classes qui héritent d’EntityObject et les types simples.<br />
  <br />Nous sommes donc “forcés” de lier les couches fortement (pour le moment).</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ria, l&#8217;update et les identifiants composites</title>
		<link>https://blog.developpez.com/bdevuyst/p8655/dotnet-net/silverlight/ria_update_entity_id_composite</link>
		<comments>https://blog.developpez.com/bdevuyst/p8655/dotnet-net/silverlight/ria_update_entity_id_composite#comments</comments>
		<pubDate>Wed, 24 Feb 2010 10:32:41 +0000</pubDate>
		<dc:creator><![CDATA[benji_dv]]></dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WCF Ria Services]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Premier post sur développez ! Et un petit tip pour tout ceux qui utilisent WCF RIA Services. Récemment, j&#8217;ai été confronté à un petit souci de design de modèle de donnée, qui a engendré un bug auprès de RIA. Soit le cas suivant : Je dispose donc (en base de données) de 5 tables : ModèlePièce identifié par IdModelePiece Fournisseur identifié par IdFournisseur Pièce Une pièce correspond à un modèle fournit par un fournisseur. L&#8217;identifiant [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Premier post sur développez ! <img src="https://blog.developpez.com/bdevuyst/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p>Et un petit tip pour tout ceux qui utilisent WCF RIA Services.</p>
<p>Récemment, j&rsquo;ai été confronté à un petit souci de design de modèle de donnée, qui a engendré un bug auprès de RIA.</p>
<p>Soit le cas suivant :<br />
<img src="http://blog.developpez.com/media/PostRIASchemaPb.png" width="295" height="334" alt="Ria-Identity-Pb" /></p>
<p>Je dispose donc (en base de données) de 5 tables :</p>
<p><b>ModèlePièce</b> identifié par </p>
<ul>
<li>IdModelePiece</li>
</ul>
<p><b>Fournisseur</b> identifié par </p>
<ul>
<li>IdFournisseur</li>
</ul>
<p><b>Pièce</b><br />
Une pièce correspond à un modèle fournit par un fournisseur.<br />
L&rsquo;identifiant de la pièce est composite : </p>
<ul>
<li>Id du fournisseur</li>
<li>l&rsquo;id du modèle.</li>
</ul>
<p><b>Machine</b><br />
Une machine correspond à un modèle d&rsquo;outil (par exemple), qui est composé de pièces.<br />
La machine est identifiée par :</p>
<ul>
<li>IdMachine</li>
</ul>
<p><b>CompositionMachine</b><br />
Cette table sert à lié les pièces aux machines.<br />
Donc, l&rsquo;identifiant est (en composition naturelle) composite et plus complexe (quoi que <img src="https://blog.developpez.com/bdevuyst/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /> ) : </p>
<ul>
<li>Id de la pièce (composé de idFournisseur + IdModelePiece)</li>
<li>Id de la machine (IdMachine)</li>
</ul>
<p>Dans ce cas précis, RIA ne pourra mettre à jour les données de la table CompositionMachine !</p>
<p>La raison principale semble liée à la méthode GetIdentity() qui ne retourne pas correctement l&rsquo;id d&rsquo;une clé composite, elle même constituée d&rsquo;une clé étrangère composite + un autre clé étrangère</p>
<p>Donc, si d&rsquo;aventure vous utiliser RIA, la solution doit impérativement passer par :<br />
<img src="http://blog.developpez.com/media/PostRIASchemaOk_01.png" width="294" height="368" alt="Ria-Identity-Ok" /></p>
<p>Chaque table a son id propre (style guid ou entier auto incrémenté) + une contrainte d&rsquo;unicité sur ce qui aurait pu être une clé primaire (en conception naturelle). Cela permet d&rsquo;éviter les composites dans les clés étrangères.</p>
<p>Dans ce cas de figure, RIA n&rsquo;est pas confronté à une clé primaire, constituée de clés étrangères, dont un élément au moins est composite.</p>
<p>Ce qui pose donc problème à RIA est bien le fait d&rsquo;être confronté à une clé primaire constituée de clé étrangères dont une au moins qui est composite.</p>
<p>C&rsquo;est tordu, mais fallait le savoir!</p>
<p>Espérons qu&rsquo;en v4 cela soit corrigé !</p>
<p>Ajouté le 04/03/2010<br />
Le message exacte de l&rsquo;exception était :<br />
Unable to cast object of type &lsquo;System.Windows.Ria.Data.EntityKey`2[System.String,System.Int32]&rsquo; to type &lsquo;System.Windows.Ria.Data.EntityKey`2[System.Int32,System.String]&rsquo;.&nbsp;&raquo;</p>
<p>Autres liens parlant du problème : </p>
<p><a href="http://forums.silverlight.net/forums/p/130384/291497.aspx">http://forums.silverlight.net/forums/p/130384/291497.aspx</a><br />
<a href="http://betaforums.silverlight.net/forums/t/117417.aspx">http://betaforums.silverlight.net/forums/t/117417.aspx</a><br />
<a href="http://forums.silverlight.net/forums/t/115342.aspx">http://forums.silverlight.net/forums/t/115342.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
