2011-07-27 74 views
1

我有以下代碼:WCF RIA:LoadOperation不刷新數據

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

當我執行該語句的第二次,它不拿起從數據庫中新的變化?

任何想法?

感謝,

裏克

+0

你是否試圖在Load上指定LoadBehavior? – Jehof

+0

不,我該怎麼做? – RickSarvos23

回答

1

試試這個:(我爆發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,我認爲這解釋了您所得到的行爲。

+0

謝謝你完美的作品! – RickSarvos23