public IReadOnlyList <IModelEntity> GetRelatedEntities(IModelEntity entity, EntityRelationType relationType, bool recursive = false) { return(_graph.GetConnectedVertices(entity, (otherEntity, relationship) => relationship.Type == relationType.Type && relationship.IsEntityInRelationship(otherEntity, relationType.Direction), recursive)); }
public MRelation(EntityRelationType type, MEntityPair lower, MEntityPair higher, float dis, float angle, bool shareObject) { relationType = type; lowerEntity = lower; higherEntity = higher; distance = dis; this.angle = angle; this.shareObject = shareObject; }
public RelatedEntityCueViewModel(IArrangedDiagram diagram, IDiagramNode diagramNode, EntityRelationType descriptor) : base(diagram) { _diagramNode = diagramNode; _entityRelationType = descriptor; SubscribeToModelEvents(); SubscribeToDiagramEvents(); RecalculateVisibility(); }
internal override IEntityRelationManager CreateEntityRelationManager(EntitySet ForeignEntitySet, EntitySet RelatedEntitySet) { if (entityRelationManagerCreator != null) { return(entityRelationManagerCreator(this, (EntitySet <TForeignEntity>)ForeignEntitySet, (EntitySet <TRelatedEntity>)RelatedEntitySet)); } if (ForeignEntitySet.EntityType != ForeignType) { throw new CriticalException($"EntityRelation<{ForeignType.Name}, {RelatedType.Name}>.CreateEntityRelationManager Foreign EntitySet {ForeignEntitySet.EntityType.Name} Type Is Not Equal To EntityRelation Foreign {ForeignType.Name} Type"); } if (RelatedEntitySet.EntityType != RelatedType) { throw new CriticalException($"EntityRelation<{ForeignType.Name}, {RelatedType.Name}>.CreateEntityRelationManager Related EntitySet {RelatedEntitySet.EntityType.Name} Type Is Not Equal To EntityRelation Related {RelatedType.Name} Type"); } Type typeEntityRelationManager = null; if (EntityRelationType.IsOneToMany()) { typeEntityRelationManager = typeof(OneToManyEntityRelationManager <, ,>).MakeGenericType(ForeignType, ForeignEntitySet.KeyType, RelatedType); } else if (EntityRelationType.IsOneToOne()) { typeEntityRelationManager = typeof(OneToOneEntityRelationManager <, ,>).MakeGenericType(ForeignType, ForeignEntitySet.KeyType, RelatedType); } else { throw new CriticalException($"EntityRelation<{ForeignType.Name}, {RelatedType.Name}>.CreateEntityRelationManager {EntityRelationType} EntityRelationType Is Not Supported"); } ConstructorInfo ctr = typeEntityRelationManager.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(EntityRelation <TForeignEntity, TRelatedEntity>), typeof(EntitySet <TForeignEntity>), typeof(EntitySet <TRelatedEntity>) }, null); ParameterExpression entityRelation = Expression.Parameter(typeof(EntityRelation <TForeignEntity, TRelatedEntity>), "EntityRelation"); ParameterExpression foreignEntitySet = Expression.Parameter(typeof(EntitySet <TForeignEntity>), "ForeignEntitySet"); ParameterExpression relatedEntitySet = Expression.Parameter(typeof(EntitySet <TRelatedEntity>), "RelatedEntitySet"); entityRelationManagerCreator = Expression.Lambda <Func <EntityRelation <TForeignEntity, TRelatedEntity>, EntitySet <TForeignEntity>, EntitySet <TRelatedEntity>, IEntityRelationManager> >(Expression.New(ctr, entityRelation, foreignEntitySet, relatedEntitySet), entityRelation, foreignEntitySet, relatedEntitySet).Compile(); return(entityRelationManagerCreator(this, (EntitySet <TForeignEntity>)ForeignEntitySet, (EntitySet <TRelatedEntity>)RelatedEntitySet)); }
/// <summary> /// Gets the JOIN clause for the specified relation type. /// </summary> /// <param name="relationType"> /// The relation type. /// </param> /// <returns> /// The JOIN clause as a <see cref="string"/>. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="relationType"/> is not one of the named enumerations. /// </exception> private static string GetJoinClause(EntityRelationType relationType) { string joinType; switch (relationType) { case EntityRelationType.InnerJoin: joinType = InnerJoinClause; break; case EntityRelationType.LeftJoin: joinType = LeftJoinClause; break; default: throw new ArgumentOutOfRangeException(nameof(relationType)); } return(joinType); }
public ShowRelatedNodeButtonViewModel(IArrangedDiagram diagram, EntityRelationType relationType) : base(diagram, relationType.Name) { _relationType = relationType; SubscribeToModelEvents(); }
public bool Equals(EntityRelationType other) { return(Type.Equals(other.Type) && Direction == other.Direction); }
internal void Add <TForeignEntity, TRelatedEntity>(EntityRelationType EntityRelationType, Expression <Func <TRelatedEntity, object> > expPropForeignKey, Expression <Func <TRelatedEntity, object> > expPropForeignReference) where TForeignEntity : Entity <TForeignEntity> where TRelatedEntity : Entity <TRelatedEntity> { if (EntityContextConfiguration.CheckConfigured) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, {EntityContextConfiguration.EntityContextType.Name} Configuration Already Is Configured, Can Not Add Any Entity Relation After Configuration"); } Type typeForeign = typeof(TForeignEntity); Type typeRelated = typeof(TRelatedEntity); PropertyInfo propForeignKey = expPropForeignKey.GetPropInfo(); PropertyInfo propForeignReference = expPropForeignReference.GetPropInfo(); if (props.ContainsKey(propForeignKey)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeRelated.Name}.{propForeignKey.Name}] Foreign Key Property Already Exist"); } if (props.ContainsKey(propForeignReference)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeRelated.Name}.{propForeignReference.Name}] Foreign Reference Property Already Exist"); } if (!EntityContextConfiguration.Entities.Contains(typeForeign)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeForeign.Name}] Is Not Defined As Acceptable Type In {EntityContextConfiguration.EntityContextType.Name} Configuration"); } if (!EntityContextConfiguration.Entities.Contains(typeRelated)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeRelated.Name}] Is Not Defined As Acceptable Type In {EntityContextConfiguration.EntityContextType.Name} Configuration"); } if (!EntityContextConfiguration.EntityKeys.Contains(typeForeign)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeForeign.Name}] Key Is Not Defined In {EntityContextConfiguration.EntityContextType.Name} Configuration"); } if (!EntityContextConfiguration.EntityKeys.Contains(typeRelated)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeRelated.Name}] Key Is Not Defined In {EntityContextConfiguration.EntityContextType.Name} Configuration"); } if (EntityContextConfiguration.EntityTrackings.IsExcepted(propForeignKey)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeRelated.Name}.{propForeignKey.Name}] Is Excepted From Tracking In {EntityContextConfiguration.EntityContextType.Name} Configuration"); } if (EntityContextConfiguration.EntityTrackings.IsExcepted(propForeignReference)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [{typeRelated.Name}.{propForeignReference.Name}] Is Excepted From Tracking In {EntityContextConfiguration.EntityContextType.Name} Configuration"); } if (typeForeign != propForeignReference.PropertyType) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, {propForeignReference.PropertyType.Name} Is Not Expected Type For [{propForeignReference.Name}] Foreign Property [{typeForeign.Name} Is Expected Type]"); } if (typeRelated != propForeignReference.DeclaringType) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, {propForeignReference.DeclaringType.Name} Type Is Not Expected Owner For [{propForeignReference.Name}] Foreign Property [{typeRelated.Name} Type Is Expected Owner]"); } string getForeignKeyType() => (propForeignKey.PropertyType.IsGenericType && propForeignKey.PropertyType.IsGenericTypeDefinition == false && propForeignKey.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) ? $"Nullable<{propForeignKey.PropertyType.GenericTypeArguments[0].Name}>" : $"{propForeignKey.PropertyType.Name}"; PropertyInfo propForeignEntityKey = EntityContextConfiguration.EntityKeys.GetPropEntityKey(typeForeign); if (!propForeignKey.HasSameTypeAs(propForeignEntityKey) && !propForeignKey.HasSameTypeAsNullable(propForeignEntityKey)) { throw new EntityContextConfigurationException($"Configuration EntityRelation Add Failed, [({getForeignKeyType()}){typeRelated.Name}.{propForeignKey.Name}] Type Is Not Equal To [({propForeignEntityKey.PropertyType.Name}){typeForeign.Name}.{propForeignEntityKey.Name}] Or Nullable Of That Type"); } EntityRelation relation = new EntityRelation <TForeignEntity, TRelatedEntity>(EntityRelationType, propForeignKey, propForeignReference, null); entityRelations.Add(relation); if (!types.Contains(typeForeign)) { types.Add(typeForeign); } if (!types.Contains(typeRelated)) { types.Add(typeRelated); } props.Add(propForeignKey, relation); props.Add(propForeignReference, relation); if (!relations_Of_foreignTypes.TryGetValue(typeRelated, out HashSet <EntityRelation> foreignType_relations)) { relations_Of_foreignTypes.Add(typeRelated, foreignType_relations = new HashSet <EntityRelation>()); } foreignType_relations.Add(relation); if (!relations_Of_relatedTypes.TryGetValue(typeForeign, out HashSet <EntityRelation> relatedType_relations)) { relations_Of_relatedTypes.Add(typeForeign, relatedType_relations = new HashSet <EntityRelation>()); } relatedType_relations.Add(relation); }
public IReadOnlyList <IModelEntity> GetUndisplayedRelatedModelEntities(IDiagramNode diagramNode, EntityRelationType relationType) { var displayedDiagramNodes = Nodes; return(Model .GetRelatedEntities(diagramNode.ModelEntity, relationType) .Where(i => displayedDiagramNodes.All(j => j.ModelEntity != i)).ToArray()); }
/// <summary> /// Initializes a new instance of the <see cref="EntityRelation"/> class. /// </summary> /// <param name="relationType"> /// The relation type. /// </param> public EntityRelation(EntityRelationType relationType) { this.RelationType = relationType; }
public RoslynSymbolRelation(INamedTypeSymbol baseSymbol, INamedTypeSymbol relatedSymbol, EntityRelationType entityRelationType) { BaseSymbol = baseSymbol; RelatedSymbol = relatedSymbol; EntityRelationType = entityRelationType; }
internal EntityRelation(EntityRelationType EntityRelationType, PropertyInfo PropForeignKey, PropertyInfo PropForeignReference, PropertyInfo PropRelated) : base(EntityRelationType, PropForeignKey, PropForeignReference, PropRelated) { }