WCF RIA:LoadOperation 不刷新数据 [英] WCF RIA : LoadOperation Not Refreshing Data
问题描述
我有以下代码:
LoadOperationClarificationsLP = context.Load(context.GetClearificationsQuery().Where(o => o.ProjectID == ((App)Application.Current).Project.ProjectID).OrderBy(o => o.RaisedOn));ClearificationsLP.Completed += delegate {//Stuff };
当我第二次执行这个语句时,它没有从数据库中获取新的更改??
有什么想法吗?
谢谢,
瑞克
试试这个:(我把 GetClearifictionsQuery 打出来只是为了让代码更清晰,是你要注意的加载行为)
<前><代码>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 };此外,请查看此处以确保您选择了正确的 LoadBehavior(有 3 个):
默认行为(如果你没有通过)是 LoadBehavior.KeepCurrent,我认为这解释了你得到的行为.
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
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):
The default behavior (if you don't pass one) is LoadBehavior.KeepCurrent, which I think explains the behavior that you are getting.
这篇关于WCF RIA:LoadOperation 不刷新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!