updating object from different datacontext RRS feed

  • Question

  • Hello,

    I have problem that I use method which creates dataContext then I get object from that DataContext entity1. Then I give this object (entity1) as argument to other method in different class. Then in that method I change that entity1 object but I dont have dataContext from which I took this object so how can I update that entity1 ?

    thanks for help
    Monday, December 14, 2009 7:27 PM


  • Hi snorlaks,

    You can instance another DataContext and fetch a new entity object according to the ID of the object that you pass from another class. Modify the new entity object and then call the SubmitChanges() method.

    In fact a better way I think is that you just pass the Id of the entity object that you want to modify, fetch the new one, make changes and then call the SubmitChanges() method.

    I hope this helps you.

    Best regards, Charlie Lee Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by snorlaks Wednesday, December 16, 2009 4:08 PM
    Wednesday, December 16, 2009 9:47 AM