Entity framework 4, update specific properties

血红的双手。 提交于 2020-01-17 05:11:06

问题


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.


回答1:


Use:

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


来源:https://stackoverflow.com/questions/6947950/entity-framework-4-update-specific-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!