Search code examples
dynamics-crmxrm

XrmServiceContext object is not getting the latest data from CRM


i have a wcf which connects to crm (on prem) to retrieve an account record. i can see when the entity is retrieved it does not hold the current record i.e. some field will still hold the old column value. i tried with various merge option with no avail. please see the code below

using (XrmServiceContext cContext = new XrmServiceContext(con))
{                
    Entity ent = cContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME, AccountId, new ColumnSet(true));
}

any suggestions?


Solution

  • Is it possible the data is being cached?

    cContext.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);

    I took this approach for a CrmOrganizationServiceContext, so perhaps the same theory applies.