Hello everybody :-)
I got a question about inserting an entity with dependent entities using RIA Services (With Silverlight 4.0).
Let's say I have an Entity in my (sql) database called "Beer" and one called "Supplier", with a relationship: Beer 1 - n Supplier. There are multiple suppliers for one kind of beer.
Now there's the following use case: The user enters a new beer with, let's say, 5 suppliers.
On the silverlight view I now got two DomainDataSource
's. On the Beer DomainDataSource
I add and submit the new beer and on the Supplier DomainDataSource
I submit the now suppliers, which contain a foreign key which links them to the beer.
My question is: How can I make sure that the Beer gets submitted first and afterwards the dependent (remember the foreign key) Suppliers?
I am aware that I could simply chain up the SubmitChanges()
using the OnSubmitted
event. But this solution is pretty... well... lame. It makes for some really ugly code.
Thanks for all your numerous ideas!