How to update a CRM 2011 Entity using LINQ in a Plugin?

后端 未结 3 844
难免孤独
难免孤独 2021-01-11 15:52

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.



        
3条回答
  •  旧时难觅i
    2021-01-11 16:17

    No need to download the whole Contact record if you already have the Id and you just need to update a field or two. You also don't need the OrganizationServiceContext - just the Service. Try something like:

    var c = new contact() {
      Id = targetEntity.Id,
      new_CustomField = "Updated"
    }
    
    service.Update(c);
    

    This will save the roundtrip of querying for the contact first.

提交回复
热议问题