ADO.NET Data Service doesn't Update
I've a problem updating objects with the ADO.NET Data Services.
First I've create a service, which can load and store the data. Its a basic data context which implements the IUpdatable-interface.
After that, I've created a simple service-client. I just created it with the 'Add Service'-reference in Visual Studio. Basically this service seams to work. I can query for the objects and store new objects. However I cannot update objects.
This is my update-code on the client:
var ctx =
new TeamDataContext(new Uri("http://localhost:8637/TeamInfoService.svc"));
var team = ctx.Teams.First();
team.TeamName = "New Team Name";
ctx.UpdateObject(team);
ctx.SaveChanges();
What my main issue is, that IUpdatable.SetValue() isn't called for the object which I want to update. Only the IUpdatable.SaveChanges() is called without updating the objects on the server.
When I create a new object, the IUpdatable.SetValue is called on the server to set the property.
So what I am doing wrong? Are my expectations wrong? Is IUpdatable开发者_如何转开发.SetValue supposed to be called when updating a object? Or do I need to do additional things to do updates?
Edit: I just watched the HTTP-requests between the client and the server. The client send a HTTP-Merge request with the changes. However I still don't know why the changes aren't stored.
I've just found out whats the issue and feel like an idiot right now. The TeamName-property was the Key of the object. Of course, when you change the key, it actually cannot find the object to update anymore. And therefore it cannot update the property.
So, never try to update the key of the object =)
精彩评论