如何在插件中使用LINQ更新CRM 2011实体? [英] How to update a CRM 2011 Entity using LINQ in a Plugin?
本文介绍了如何在插件中使用LINQ更新CRM 2011实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们能够创建新实体,没有任何问题,但是更新插件中的现有实体似乎不起作用.这是针对CRM 2011的.
We are able to create new entities without any issues, but updating an existing entity in a plugin this does not appear to be working. This is for CRM 2011.
var crmContext = new CustomCrmContext(service);
var contact = crmContext.Contact.FirstOrDefault(c=>c.Id == targetEntity.Id);
contact.new_CustomField = "Updated";
crmContext.SaveChanges();
推荐答案
You have to mark the object as modified in order to get it submitted to the server. See OrganizationServiceContext.UpdateObject (Entity)
您应该添加
crmContext.UpdateObject(contact);
在crmContext.SaveChanges();
这篇关于如何在插件中使用LINQ更新CRM 2011实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文