Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

weird data association error?

$
0
0

Hello, I'm experiencing a weird data association error:

1. I associate some n:n data through a class method called by my PostCaseCreate plugin.
2. I call a test method immediately after the method in step 1, to validate that the data exists as expected
3. I call the same test method further downstream, but the data no longer exists as expected. Specifically, trying to access the data returns the following cast error:  "Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'MyProject.Entities.Contact'"

The weird part is that this is *shared* code that works without error for another incident, created via a different scenario. Here's the code that I'm using to access the data:

    using (var xrm = new XrmContext(orgService))
    {
        xrm.MergeOption = Microsoft.Xrm.Sdk.Client.MergeOption.NoTracking;
        xrm.LoadProperty(incident, "new_MyContacts");
        var myContacts = incident.new_MyContacts;
    }

Now that I've established that the code above works at 1 point, but then breaks at a later point, I can probably spend some time to determine, at what point the code breaks.  However, this seems like a weird error, especially since this is shared code working for another scenario, so I was wondering if anyone had any ideas about what might be causing this issue, or how to fix?


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>