I have problem to call WCF RIA service again to refresh data at client side. Here is my case:
At server side, a domain service is something like:
public IQueryable<Person> GetPersonByID(int id)
{
var result = this.ObjectContext.Persons.
Where(e => e.PersonID == id);
return result; // check point 1
}
At client side, I make a call in the following way (this is call by a button I called "refresh" button):
this._amsService.Context.Load<Person>(
this._amsService.Context.GetPersonByIDQuery(this.Person.ID),
LoadBehavior.RefreshCurrent,
result =>
{
this.Person = result.Entities.FirstOrDefault(); //check point 2
this.RaisePropertyChanged("Person");
}, null);
Here is what I'm trying:
Suppose I have a person in DB with data say personID=1
, Age = 16
.
Then run the app, I get the data in the right way.
then go to database, update data with SQL to change
Age = 20
.Then back to app and click the "refresh" button to make a new call, but the age is not updated to
20
, it is still16
.
I run the app in debug mode, and check the data:
At check point 1, I check data in result, it is fine, Age = 20
.
At check point 2, I check data in result.Entities
, the data has not been refreshed, it's still Age = 16
.
I have tried LoadBehavior.MergeIntoCurrent,LoadBehavior.RefreshCurrent
, but no success.
So I need to refresh the SL app host page to reload the whole SL app, then I can see the new data. This is not acceptable to end users.
I don't understand why. I also try to use fiddler to catch the data when click on refresh button, the data did get the latest Age = 20
.
How to resolve this problem?