Update object created in another datacontext?

Check out this article: omaralzabir.com/linq_to_sql__how_to_atta... Also, in your example, for update, try doing: var item = new ObjectBeingUpdated(); //copy over properties from old object to new object, make sure pk's match //Attach this new object Something similar worked for my coworker I believe UPDATE: Check this out for more info about attach: blogs.msdn.com/b/dinesh.kulkarni/archive....

Check out this article: omaralzabir.com/linq_to_sql__how_to_atta... Also, in your example, for update, try doing: var item = new ObjectBeingUpdated(); //copy over properties from old object to new object, make sure pk's match //Attach this new object Something similar worked for my coworker I believe. UPDATE: Check this out for more info about attach: blogs.msdn.com/b/dinesh.kulkarni/archive....

Copy over properties from old object to new object, make sure pk's match As I said before it will work but it is not "beatiful" way. How about 42 fields in table? Sure I can use system.reflection.

But is there any "beautiful" method to update object created in another datacontext? – takayoshi Dec 8 '10 at 19:34.

You could use the following pattern: Fetch existing object from repository Use AutoMapper to copy properties Save your object back.

This is what I did... However when saving xelements or any data that is mapped to an xml field you will find that this does not work... – Haroon Mar 16 at 23:20.

Linq2SQL: Update object not created in datacontext. I've tried to use . Attach(this, oldObjectFromBase) but always I've an errors.

I know I can get object from database and manually transfer data from modified object, but there will be new fields. It means that I must always append these new fields in Save() method. Is there any "beautiful" method to update object created in another datacontext?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions