开发者

Entity framework 4, update specific properties

开发者 https://www.devze.com 2023-03-26 04:22 出处:网络
I\'m used to using code first where I can do: db.Users.Attach(user)开发者_开发技巧; db.Entry(user).Property(propertyName).IsModified = true;

I'm used to using code first where I can do:

db.Users.Attach(user)开发者_开发技巧;
db.Entry(user).Property(propertyName).IsModified = true;

How do I do this with a DataModel approach?

I do not have the Entry method on my datacontext.


Use:

context.Users.Attach(user);
ObjectStateEntry entry = context.ObjectStateManager.GetObjectStateEntry(user);
entry.SetModifiedProperty(propertyName);
0

精彩评论

暂无评论...
验证码 换一张
取 消