silverlightsubmitchangesdomaindatasourcedomaincontext

Silverlight DomainContext load with two separate DomainDataSources


I have a confusion regarding DataContext which i would like someone to confirm or comment please.

In plain English, I believe a DataContext is a container which can be filled with entities upon load.

e.g. I have two entities named Customers and Orders. I now declare a new DomainContext

var ctx = new MyWebServices.MyDomainContext();

I load Customers in a DomainDataSource like this:

DomainDataSource ddsCustomer = new DomainDataSource();
ddsCustomer.context = ctx;
ddsCustomer.query = ctx.LoadCustomerQuery();
ddsCustomer.Load();

Now if I load the Orders using the same domain context

DomainDataSource ddsOrder = new DomainDataSource();
ddsCustomer.context = ctx;
ddsCustomer.query = ctx.LoadOrdersQuery();
ddsCustomer.Load();

After I submit changes ctx.SubmitChanges(), will the DomainContext go back to the server and commit all changes to server, including Customers and Orders, both? Even new records added and existing edited to these both Entities?

I am new to Silverlight and wanted a firm concept of how DataContext works, I've gone through the whitepapers but may be couldn't find the answer I was looking for.


Solution

  • Yes, myDataContext.SubmitChanges() calls the protected Ria.Entity.AcceptChanges() method on any Entity that has been loaded into the collections on the DomainContext.