private string GetCacheKey( EntityFilters metadataFlags, EntityFilters entityFlags, string entityName, string attributeName, string sortExpression) { CacheParameters cacheParameters = Owner.GetCacheParameters(); return(cacheParameters.CacheKey.GetCacheKey( Context, Owner, Owner, delegate { string cacheKey = "MetadataFlags={0}:entityFlags={1}:EntityName={2}:AttributeName={3}:SortExpression={4}".FormatWith( metadataFlags, entityFlags, entityName, attributeName, sortExpression); return "Adxstudio:Type={0}:ID={1}:{2}".FormatWith(Owner.GetType().FullName, Owner.ID, cacheKey); })); }
private IEnumerable <string> GetCacheDependencies(QueryBase query, IEnumerable entities) { CacheParameters cacheParameters = Owner.GetCacheParameters(); var dependencies = new List <string>(); // get the global dependencies foreach (CacheKeyDependency ckd in cacheParameters.Dependencies) { dependencies.Add(ckd.GetCacheKey(Context, Owner, query)); } // get the item dependencies foreach (Entity entity in entities) { dependencies.Add("xrm:dependency:entity:{0}:id={1}".FormatWith(entity.LogicalName, entity.Id)); foreach (CacheKeyDependency ckd in cacheParameters.ItemDependencies) { dependencies.Add(ckd.GetCacheKey(Context, Owner, entity)); } } // add other dependencies if (query is QueryExpression) { foreach (LinkEntity linkEntity in GetLinkEntities(query as QueryExpression)) { dependencies.Add("xrm:dependency:entity:{0}".FormatWith(linkEntity.LinkToEntityName)); } // add query entity dependency var queryEntity = "xrm:dependency:entity:{0}".FormatWith(((QueryExpression)query).EntityName); if (!dependencies.Contains(queryEntity)) { dependencies.Add(queryEntity); } } else if (query is QueryByAttribute) { dependencies.Add("xrm:dependency:entity:{0}".FormatWith((query as QueryByAttribute).EntityName)); } return(dependencies); }
private string GetCacheKey(QueryBase query) { if (_cacheKey == null) { CacheParameters cacheParameters = Owner.GetCacheParameters(); _cacheKey = cacheParameters.CacheKey.GetCacheKey( Context, Owner, Owner, delegate { string serializedQuery = Serialize(query); Tracing.FrameworkInformation("CrmDataSourceView", "GetCacheKey: QueryByAttribute", serializedQuery.GetHashCode().ToString(CultureInfo.InvariantCulture)); return("Adxstudio:Type={0}:ID={1}:Hash={2}".FormatWith(Owner.GetType().FullName, Owner.ID, serializedQuery.GetHashCode())); }); } return(_cacheKey); }
private IEnumerable <string> GetCacheDependencies(IEnumerable results) { CacheParameters cacheParameters = Owner.GetCacheParameters(); var dependencies = new List <string>(); dependencies.Add("xrm:dependency:metadata:*"); // get the global dependencies foreach (CacheKeyDependency ckd in cacheParameters.Dependencies) { dependencies.Add(ckd.GetCacheKey(Context, Owner, Owner)); } // get the item dependencies foreach (object result in results) { foreach (CacheKeyDependency ckd in cacheParameters.ItemDependencies) { dependencies.Add(ckd.GetCacheKey(Context, Owner, result)); } } return(dependencies); }