Silverlight DomainContext load with two separate DomainDataSources

烈酒焚心 提交于 2019-12-11 16:49:03

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/11114015/silverlight-domaincontext-load-with-two-separate-domaindatasources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!