开发者

Silverlight(MVVM, Prism) + WCF Data Services + Context.UpdateObject = Context not tracking entity

Silverlight 4 with Prism (MVVM pattern). I'm building a filter which is a datatype from the WCFDataService(Entity Framework). I get it from the context开发者_如何学Python, then make a change to an attribute and call Context.UpdateObject(filter); I get the dreaded "Context not tracking entity".

So I add in a try/catch that does this before calling the update method: context.AttachTo("Filters", f); This works for items that were never pulled from the db ahead of time, but fails with "different entity with the same resource Uri" on objects already known to the context (recently used).

So which is it? On one hand it's already tracking it, then on the other its not? I would love to be able to just pull it from the context/db again, but in Silverlight everything is async. I would be in the same boat I am in now.

Ideas?


I made the mistake of passing around the same data context. Creating a new one for the specific purpose solved the problem.(One for each type of CRUD)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜