ADO.NET Data Services Bug...

Silverlight Logo

There is a bug in the current ADO.NET Data Services that ships with .NET 3.5 SP1 Beta 1.  The problem involves saving related data.  If the child object requires the relationship to the parent object, the update fails.

For example, if you have a Customer with a list of Orders.  The relationship between the Customers and Orders is 1...* (0 or 1...* doesn't cause this bug).  If you create a Customer and an Order to be updated with the ADO.NET Data Services client library at the same time, the current code attempts to save both the Customer and Order and then update the link between them separately.  Of course if the relationship really is 1...*, then you can't save an Order that doesn't have a customer so the update fails.  Unfortunately this can update the Customer and just ignore the error with the Order not saving. 

The only way to make this work is to relax the relationship so you can create the unrelated child object.

This is a bug in the server code and will be fixed in future builds of ADO.NET Data Services.

HTH

Comments:

Hi Shawn,
When using the Client library , this scenario would work if you save with SaveChangesOptions.Batch .
The reason this doesnt work now is because to link the newly created entity , we need the server generated key which isnt yet available on the client . In SaveChangesOptions.None , which is default , the operations ( add/delete/link) are fired as WebRequests one after the other and no state is tracked between requests. In case of SaveChangesOptions.Batch ,we analyze the operation and send everything as one request and since we can link operations together in a batch request , this succeeds . The same scenario works with SaveChangesOptions.None in the RTM .

Good info. I am not sure its not a bug, but this is a much better workaround (and perhaps should have been my behavior in any case) for this issue.


 



 
Save Cancel