2010-10-10 115 views
2

我已經創建了一個Silverlight應用程序,並有一個使用domaindatasource填充的列表框。我創建了一個按鈕,帶選中的列表項和更新的字段(在我的情況下,它被稱爲請將isDeleted) 我的域名服務是這樣的silverlight 4 RIA更新項目在domaindatasource更新後只更新

public IQueryable<Employee> GetEmployees(int storeID) 
    { 
     return this.ObjectContext.Employees.Where(e=>(e.StoreID==storeID)&&(e.IsDeleted==false)); 
    } 

在我的按鈕事件我這樣做

EmployeeRecord.IsDeleted = true; 
         dsEmployee.SubmitChanges(); 

數據庫已按預期更新,直到應用程序重新加載或I F5比我沒有看到更新。 我還應該做些什麼才能立即看到更新?

回答

3

您需要重新加載您的域上下文。請撥打以下電話:

myDomainDataSource.SubmitChanges((submitArgs) => 
      { 
       if (submitArgs.IsComplete) 
       { 
        myDomainDataSource.Load<MyType>(myDomainDataSource.MyQuery(filterTextBox.Text), System.ServiceModel.DomainServices.Client.LoadBehavior.RefreshCurrent, true); 
        if (myDataSource.CanLoad) 
         myDataSource.Load(); 
       } 
       else if (submitArgs.HasError) 
       { 
        throw submitArgs.Error; 
       } 
      }, null);