WCF RIA:LoadOperation 不刷新数据 [英] WCF RIA : LoadOperation Not Refreshing Data

查看:45
本文介绍了WCF RIA:LoadOperation 不刷新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

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 个):

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

默认行为(如果你没有通过)是 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):

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.

这篇关于WCF RIA:LoadOperation 不刷新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆