MS动态CRM 2011 SDK - 使用后期绑定更新实体记录 [英] MS Dynamics CRM 2011 SDK - Update entity record using late-binding
本文介绍了MS动态CRM 2011 SDK - 使用后期绑定更新实体记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
没有人知道如何节省使用SDK后期绑定实体的变化动态CRM 2011
does anyone know how to save changes to a late-bound entity using the 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!" );
}
感谢所有帮助:)
Thanks for all help :)
推荐答案
试试这个:
pet["foodtype"] = "Seaweed";
xrm.UpdateObject( pet );
xrm.SaveChanges();
编辑:上下文当前没有跟踪宠物实体
意味着你从获取对象检索
未连接到服务上下文。有附加的方法
的做到了这一点。
"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();
这篇关于MS动态CRM 2011 SDK - 使用后期绑定更新实体记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文