MS Dynamics CRM 2011 SDK – 使用后期绑定更新实体记录
有没有人知道如何使用SDK for Dynamics CRM 2011保存对后期绑定实体的更改?
这就是我尝试过的:
// retrieve and modify a pet... // (This part works) Guid findId = new Guid("6CA57D73-30CC-E111-B155-00505630052F"); ColumnSet attributes = new ColumnSet(new string[] { "name", "foodtype" }); // try to retrieve // (this also works) pet = xrm.Retrieve("pet", findId, attributes); if( pet!=null ) { Console.WriteLine( String.Format( "Retrieved pet {0} successfully!", pet["name"].ToString() )); // update attributes pet["foodtype"] = "Seaweed"; // (from here doesn't seem to work) // save pet xrm.SaveChanges(); Console.WriteLine( "Done!" ); }
谢谢你的帮助:)
试试这个:
pet["foodtype"] = "Seaweed"; xrm.UpdateObject( pet ); xrm.SaveChanges();
编辑: "The context is not currently tracking the 'pet' entity"
意味着您从Retrieve
获得的对象未附加到服务上下文。 有一种方法可以做到这一点。
xrm.Attach( pet ); pet["foodtype"] = "Seaweed"; xrm.UpdateObject( pet ); xrm.SaveChanges();
这有效:
上述就是C#学习教程:MS Dynamics CRM 2011 SDK – 使用后期绑定更新实体记录分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
pet["foodtype"] = "Seaweed"; pet.EntityState = EntityState.Changed; // not sure if this is really needed // save pet xrm.Update(pet);
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1001422.html