0

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.

Rodia
  • 1,407
  • 8
  • 22
  • 29
Thr3e
  • 358
  • 1
  • 6
  • 22

1 Answers1

0

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

  • even the DomainContext has been loaded by two or more different DomainDataSources? .... and if instead of SaveChanges via Domain Context, we go ahead and SubmitChanges to one of the above DomainDataSource, does it also submit the whole context back to the server and All Entities that has been loaded into the collections on the DomainContext will be updated? ...... thx – Thr3e Jun 20 '12 at 08:38