static void Schema_Saving(RoleEntity role) { if (!role.IsNew && role.Roles != null && role.Roles.IsGraphModified) { using (new EntityCache(EntityCacheType.ForceNew)) { EntityCache.AddFullGraph(role); DirectedGraph <RoleEntity> newRoles = new DirectedGraph <RoleEntity>(); newRoles.Expand(role, r1 => r1.Roles.Select(a => a.RetrieveAndRemember())); foreach (var r in Database.RetrieveAll <RoleEntity>()) { newRoles.Expand(r, r1 => r1.Roles.Select(a => a.RetrieveAndRemember())); } var problems = newRoles.FeedbackEdgeSet().Edges.ToList(); if (problems.Count > 0) { throw new ApplicationException( AuthMessage._0CyclesHaveBeenFoundInTheGraphOfRolesDueToTheRelationships.NiceToString().FormatWith(problems.Count) + problems.ToString("\r\n")); } } } }
protected internal virtual MappingContext <T> ApplyChanges <T>(ControllerBase controller, T entity, string prefix, Mapping <T> mapping, PropertyRoute route, SortedList <string, string> inputs) where T : ModifiableEntity { using (HeavyProfiler.Log("ApplyChanges", () => typeof(T).TypeName())) using (new EntityCache(EntityCacheType.Normal)) { EntityCache.AddFullGraph((ModifiableEntity)entity); RootContext <T> ctx = new RootContext <T>(prefix, inputs, route, controller) { Value = entity }; mapping(ctx); return(ctx); } }
private static void IToolbar_Saving(IToolbarEntity tool) { if (!tool.IsNew && tool.Elements.IsGraphModified) { using (new EntityCache(EntityCacheType.ForceNew)) { EntityCache.AddFullGraph((Entity)tool); var toolbarGraph = DirectedGraph <IToolbarEntity> .Generate(tool, t => t.Elements.Select(a => a.Content).Where(c => c is Lite <IToolbarEntity>).Select(t => (IToolbarEntity)t !.Retrieve())); var problems = toolbarGraph.FeedbackEdgeSet().Edges.ToList(); if (problems.Count > 0) { throw new ApplicationException( ToolbarMessage._0CyclesHaveBeenFoundInTheToolbarDueToTheRelationships.NiceToString().FormatWith(problems.Count) + problems.ToString("\r\n")); } } } }
static void Schema_Saving(RoleEntity role) { if (!role.IsNew && role.Roles.IsGraphModified) { using (new EntityCache(EntityCacheType.ForceNew)) { EntityCache.AddFullGraph(role); var allRoles = Database.RetrieveAll <RoleEntity>(); var roleGraph = DirectedGraph <RoleEntity> .Generate(allRoles, r => r.Roles.Select(sr => sr.RetrieveAndRemember())); var problems = roleGraph.FeedbackEdgeSet().Edges.ToList(); if (problems.Count > 0) { throw new ApplicationException( AuthAdminMessage._0CyclesHaveBeenFoundInTheGraphOfRolesDueToTheRelationships.NiceToString().FormatWith(problems.Count) + problems.ToString("\r\n")); } } } }