Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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() ?

like image 649
schmoopy Avatar asked Jul 26 '26 07:07

schmoopy


1 Answers

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.

like image 55
Scott Ivey Avatar answered Jul 27 '26 21:07

Scott Ivey