XrmServiceContext 对象未从 CRM 获取最新数据
XrmServiceContext object is not getting the latest data from CRM
我有一个 wcf,它连接到 crm(预置)以检索帐户记录。我可以看到检索实体时它不保存当前记录,即某些字段仍将保存旧列值。我尝试了各种合并选项但无济于事。请看下面的代码
using (XrmServiceContext cContext = new XrmServiceContext(con))
{
Entity ent = cContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME, AccountId, new ColumnSet(true));
}
有什么建议吗?
保存后使用清除更改cContext.ClearChanges();
检索使用MergeOption.OverwriteChanges
或
通过传递更新的组织服务来创建新的 XrmServiceContext 对象:
var uncachedOrganizationService = new OrganizationService("Xrm");
var uncachedXrmServiceContext = new XrmServiceContext(uncachedOrganizationService);
var ent = uncachedXrmServiceContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME,AccountId,new ColumnSet(true));
是否可能正在缓存数据?
cContext.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);
我对 CrmOrganizationServiceContext
采用了这种方法,所以也许同样的理论也适用。
我有一个 wcf,它连接到 crm(预置)以检索帐户记录。我可以看到检索实体时它不保存当前记录,即某些字段仍将保存旧列值。我尝试了各种合并选项但无济于事。请看下面的代码
using (XrmServiceContext cContext = new XrmServiceContext(con))
{
Entity ent = cContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME, AccountId, new ColumnSet(true));
}
有什么建议吗?
保存后使用清除更改cContext.ClearChanges();
检索使用MergeOption.OverwriteChanges
或
通过传递更新的组织服务来创建新的 XrmServiceContext 对象:
var uncachedOrganizationService = new OrganizationService("Xrm");
var uncachedXrmServiceContext = new XrmServiceContext(uncachedOrganizationService);
var ent = uncachedXrmServiceContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME,AccountId,new ColumnSet(true));
是否可能正在缓存数据?
cContext.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);
我对 CrmOrganizationServiceContext
采用了这种方法,所以也许同样的理论也适用。