Note that there are some explanatory texts on larger screens.

plurals
  1. POCascade deletion in WCF Data Services
    primarykey
    data
    text
    <p>Is it possible to delete persistent objects graph by the single command using WCF Data Services in Silverlight? I've started with <a href="http://msdn.microsoft.com/en-us/library/ee681615%28VS.95%29.aspx" rel="nofollow noreferrer">this walkthrough</a> and added code for deletion of selected order (which contains details):</p> <pre><code>private void deleteOrder_Click(object sender, RoutedEventArgs e) { Order deletedOrder = (Order)ordersGrid.SelectedItem; // Delete the selected order. svcContext.DeleteObject(deletedOrder); // Remove the deleted order from the binding collection. ordersGrid.SelectedIndex = ordersGrid.SelectedIndex == 0 ? 1 : ordersGrid.SelectedIndex - 1; ordersBindingCollection.Remove(deletedOrder); } </code></pre> <p>When I save changes back to server, delete request is issued:</p> <pre> --batch_2009b119-0747-4019-8974-8ea7dd29963a Content-Type: multipart/mixed; boundary=changeset_b451aecf-b66d-4f0f-8e6d-8a067646b350 --changeset_b451aecf-b66d-4f0f-8e6d-8a067646b350 Content-Type: application/http Content-Transfer-Encoding: binary DELETE http://localhost:55378/PurchasesService.svc/Orders(1) HTTP/1.1 Content-ID: 90 --changeset_b451aecf-b66d-4f0f-8e6d-8a067646b350-- --batch_2009b119-0747-4019-8974-8ea7dd29963a-- </pre> <p>But it fails on the database end with the foreign key constraint violation:</p> <pre> --batchresponse_b6c22c24-17ec-409b-ba91-91784116927d Content-Type: multipart/mixed; boundary=changesetresponse_41e6e873-a5dd-446d-bda0-99405ba92a63 --changesetresponse_41e6e873-a5dd-446d-bda0-99405ba92a63 Content-Type: application/http Content-Transfer-Encoding: binary HTTP/1.1 500 Internal Server Error Content-ID: 90 Cache-Control: no-cache DataServiceVersion: 1.0; Content-Type: application/xml &lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt; &lt;error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"&gt; &lt;code&gt;&lt;/code&gt; &lt;message xml:lang="uk-UA"&gt;An error occurred while processing this request.&lt;/message&gt; &lt;/error&gt; --changesetresponse_41e6e873-a5dd-446d-bda0-99405ba92a63-- --batchresponse_b6c22c24-17ec-409b-ba91-91784116927d-- </pre> <p>I've also tried to set relation's <strong>OnDelete</strong> property to <strong>Cascade</strong> in .edmx</p> <p>Is it possible to make such deletions? Who should take care of deleting referenced objects: client or server? And how many delete requests should be sent to the server: one or N+1 (where N is number of details of given order). Maybe I'm missing some key point. Are there any WCF Data Services tutorials describing deletion of object graphs?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload