开发者

What is the best practice for committing changes using a LINQ2SQL datacontext in a Silverlight application using RIA?

I've got a Silverlight app using RIA services and LINQ2SQL and have objects in my Silverlight app.

I query all the re开发者_如何学运维cords in a table (via a LINQ query, using a datacontext) in the Silverlight app and create a user control for each object (record) and put that object into the control because I need the information later. Then later, the user makes changes to that object (stored in the control) and I want to save it back to the database.

My problem is that when I go to save the object I have no datacontext to execute SubmitChanges against. I can't attach it to a new context because it says it's already attached.

What the best practice for this situation?


Create a new DataContext, use it to retrieve the record in question, make your changes to the record, and execute SubmitChanges().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜