locked
xrmcontext loadproperty question RRS feed

  • Question

  • Hello, I have a question about usage of the XrmContext LoadProperty method. I've used this method in the past, to get a handle to relationship data for an entity.  For example, if I have an incident object, I can use the following code to get the incident annotations:

    using (var xrm = new XrmContext(localContext.OrganizationService))
    {
       xrm.MergeOption = Microsoft.Xrm.Sdk.Client.MergeOption.NoTracking;
       xrm.LoadProperty(incident, "Incident_Annotation");
       //incident.Incident_Annotation now returns a list of all Annotations associated with the incident
    }

    However, I've used this same approach, in the past, to get related entity data, and the net result was that when I called service.Update(incident), the relationship data was included with the incident, and the service attempted to insert duplicate data in the related data table.

    So, can you please explain any steps I need to take, or anything I need to be careful about, when using the LoadProperty method?  When I use LoadProperty, I'm really just interested in getting related data to access, and not interested in using the related data for persistence?

    Monday, November 4, 2013 10:09 PM