MS Dynamics CRM 2011 SDK - Update entity record using late-binding

此生再无相见时 提交于 2019-12-05 18:17:49

Try this:

pet["foodtype"] = "Seaweed";

xrm.UpdateObject( pet );
xrm.SaveChanges();

EDIT: "The context is not currently tracking the 'pet' entity" means the object you get from Retrieve is not attached to the service context. There's a method Attach that does just that.

xrm.Attach( pet );
pet["foodtype"] = "Seaweed";

xrm.UpdateObject( pet );
xrm.SaveChanges();

This works:

pet["foodtype"] = "Seaweed";
pet.EntityState = EntityState.Changed; // not sure if this is really needed
// save pet
xrm.Update(pet);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!