0

Its just a simple Linq to Entity update query i tried with the following code but it doesn't update the "User" column in the DB.

Its not even throwing any exception also,please some one point me what am missing here.

MyEntities db = new MyEntities ();

var query = from SEVTs in db.SEVTs
            where SESID == "4747747"
            select SEVTs;

foreach (var SEVTs in query) {
  SEVTs.USER = "Test";
}

db.SaveChanges();

Quite interesting, when i try the follwing query in the sql server its not update the record

update Schedwin.SEVT  
set
USER3='Test'
Where
SESID='4747747' // here i pass the value as a string

SESID data type is CHAR and its a primary key. if i pass the value as SESID=4747747 then it update that record.

Please ignore my question.

Here what i missed my input value SESID == "4747747" //this have whitespace that's why it didn't updated that particular record.

Thanks All

1 Answer 1

2

You are nor modifying SEVTs.USER, but some local variable.

(BTW: create a context in a using construct)

Sign up to request clarification or add additional context in comments.

3 Comments

,thanks for that comment,my bad i forgot to include SEVTs.User="test" in the code above, updated my question,sorry.I will definitely going to use "using".Thanks for the suggestion.
Then it is very likely that it updates a different database than the one you're looking at.
Here what i missed, my input value SESID == "4747747" //this have whitespace that's why it didn't updated that particular record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.