silverlight 4 RIA update item in domaindatasource only updates after refresh

久未见 提交于 2019-12-12 21:51:23

问题


I have created a silverlight app and have a listbox that is populated using a domaindatasource. I have created a button that takes the selected list item and updates a field (in my case its called IsDeleted) my domain service looks like this

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

In my button event I am doing this

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

The database is been updated as expected until the application is reloaded or I F5 than I don't see the update. What else should I be doing to see the update straight away?


回答1:


You need to reload your domain context. Call the following:

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);


来源:https://stackoverflow.com/questions/3899721/silverlight-4-ria-update-item-in-domaindatasource-only-updates-after-refresh

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