Dynamics crm 使用ObjectCacheManager清除XRM 2011中的缓存
在过去,我有这个Dynamics crm 使用ObjectCacheManager清除XRM 2011中的缓存,dynamics-crm,xrm,Dynamics Crm,Xrm,在过去,我有这个 2011年就不同了。有什么想法吗 它只改变了一点点: ObjectCache cache = Microsoft.Xrm.Client.Caching.ObjectCacheManager .GetInstance("Xrm"); string cachekey = String.Format("xrm:dependency:entity:{0}:id={1:D}", entity.LogicalName, entity.Id); cache.Remove(
2011年就不同了。有什么想法吗 它只改变了一点点:
ObjectCache cache = Microsoft.Xrm.Client.Caching.ObjectCacheManager
.GetInstance("Xrm");
string cachekey = String.Format("xrm:dependency:entity:{0}:id={1:D}",
entity.LogicalName, entity.Id);
cache.Remove(cachekey);
我没有找到这方面的文档,通过枚举缓存找到了密钥命名方案。可能使用这不是最佳实践,它可能会在下一个版本中再次更改?应该有更好的方法来做到这一点
[更新]
有一个问题
试试这个:
var serviceContext = (Get an OrganizationServiceContext);
var serviceContainer = serviceContext as
OrganizationServiceContainer;
var cachedOrgService = serviceContainer.Service as
CachedOrganizationService;
var orgServiceCache = cachedOrgService.Cache as
IOrganizationServiceCache;
var entity = (Get the entity that was updated);
orgServiceCache.Remove(entity.LogicalName, entity.Id);
它就像一个符咒……它只改变了一点点:
ObjectCache cache = Microsoft.Xrm.Client.Caching.ObjectCacheManager
.GetInstance("Xrm");
string cachekey = String.Format("xrm:dependency:entity:{0}:id={1:D}",
entity.LogicalName, entity.Id);
cache.Remove(cachekey);
我没有找到这方面的文档,通过枚举缓存找到了密钥命名方案。可能使用这不是最佳实践,它可能会在下一个版本中再次更改?应该有更好的方法来做到这一点
[更新]
有一个问题
试试这个:
var serviceContext = (Get an OrganizationServiceContext);
var serviceContainer = serviceContext as
OrganizationServiceContainer;
var cachedOrgService = serviceContainer.Service as
CachedOrganizationService;
var orgServiceCache = cachedOrgService.Cache as
IOrganizationServiceCache;
var entity = (Get the entity that was updated);
orgServiceCache.Remove(entity.LogicalName, entity.Id);
工作起来很有魅力