WCF RIA : LoadOperation Not Refreshing Data

谁都会走 提交于 2019-12-11 06:56:39

问题


I have the following code:

LoadOperation<Clarifications> ClarificationsLP = context.Load(context.GetClearificationsQuery().Where(o => o.ProjectID == ((App)Application.Current).Project.ProjectID).OrderBy(o => o.RaisedOn));
ClearificationsLP.Completed += delegate {//Stuff };

When I execute this statement the second time, it does not pick up new changes from the database??

Any Idea?

Thanks,

Rick


回答1:


Try this: (I broke out the GetClearifictionsQuery just to make the code more clear, it's the load behavior that you want to pay attention to)


var query = context.GetClearificationsQuery().Where((o => o.ProjectID == ((App)Application.Current).Project.ProjectID).OrderBy(o => o.RaisedOn));
LoadOperation ClarificationsLP = context.Load(query, LoadBehavior.MergeIntoCurrent);
ClearificationsLP.Completed += delegate {//Stuff };

Also, have a look here to make sure that you are choosing the correct LoadBehavior (there are 3):

http://msdn.microsoft.com/en-us/library/system.servicemodel.domainservices.client.loadbehavior(v=VS.91).aspx

The default behavior (if you don't pass one) is LoadBehavior.KeepCurrent, which I think explains the behavior that you are getting.



来源:https://stackoverflow.com/questions/6849487/wcf-ria-loadoperation-not-refreshing-data

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