schmoopy
schmoopy

Reputation: 6649

linq to sql + update table

Heres a newb question for you.

I have a multi tier environment so i dont have the origional datacontext where the item was created, thus i am having an issue getting the table to update correctly - here is what im doing:

1.) Get the object from the DAL layer 2.) make changes 3.) call update on the DAL layer and pass the modified entity 4.) on the DAL layer where im trying to update:

var a = (p => p.ID == 3);
a = myPassedInEntity
myContext.Update();

if i inspect 'a' prior to calling update it has the values of the myPassedInEntity but saving just saves the old data.

Why is there no UpdateOnSubmit() like there is InsertOnSubmit() ?

Upvotes: 3

Views: 2417

Answers (1)

Scott Ivey
Scott Ivey

Reputation: 41558

There's a couple options to fix your problems here - see the answers to this question or this one for more info. Basically your options are to use the Linq serialization so that it can cross DataContext boundaries, use a timestamp to track row versions, or update your properties one by one.

Upvotes: 2

Related Questions