You can easly do it by using this code
Please note, I set only value, that i wanted to cahnge. Another value is "id", that identifies the record.
Another interesting aspect is this
You will get an error if you don't set the fields with NOTNULL values.
another approach to it is
using (var db = new EGAIS_RUEntities()) { db.Configuration.ValidateOnSaveEnabled = false; var _rec = new CONTRAGENT() { id = 1, status = 3 }; db.CONTRAGENTS.Attach(_rec); var entry = db.Entry(_rec); entry.Property(e => e.status).IsModified = true; db.SaveChanges(); }
Please note, I set only value, that i wanted to cahnge. Another value is "id", that identifies the record.
Another interesting aspect is this
db.Configuration.ValidateOnSaveEnabled = false;
You will get an error if you don't set the fields with NOTNULL values.
another approach to it is
dbcontext.Entry(_rec).State = System.Data.Entity.EntityState.Modified; dbcontext.SaveChanges();
No comments:
Post a Comment
Note: only a member of this blog may post a comment.