/// <summary> /// Clears the cache. /// </summary> /// <param name="profileId">The profile id.</param> /// <param name="principalId">The principal id.</param> private static void ClearCache(PrimaryKeyId?profileId, PrimaryKeyId?principalId) { // user if (principalId.HasValue) { DataCache.RemoveByUser(principalId.Value.ToString()); } // profile else if (profileId.HasValue) { ProfileManager.ClearCacheForProfileUsers(profileId.Value); } XmlCommand.ClearCache(); XmlBuilder.ClearCache(); }
private void CreateRelation(string primaryClassName, string relatedClassName) { MetaClass relatedMetaClass = DataContext.Current.GetMetaClass(relatedClassName); MetaClass primaryMetaClass = DataContext.Current.GetMetaClass(primaryClassName); if (relatedMetaClass.Fields[MetaClassManager.GetPrimaryKeyName(primaryClassName)] != null) { return; } using (MetaClassManagerEditScope managerEditScope = DataContext.Current.MetaModel.BeginEdit()) { var metaField = relatedMetaClass.CreateReference(primaryMetaClass, primaryClassName, primaryClassName, true); metaField.AccessLevel = AccessLevel.Customization; metaField.Attributes.Add(Constants.Attributes.DisplayBlock, Constants.SectionName); metaField.Attributes.Add(Constants.Attributes.DisplayText, relatedClassName); metaField.Attributes.Add(Constants.Attributes.DisplayOrder, Constants.DefaultDisplayOrder); XmlBuilder.ClearCache(); managerEditScope.SaveChanges(); } }