public void AddAttribute(CrmComponent component, CrmComponent rootComponent) { if (rootComponent != null) { var emdi = EntityMetas.Where(x => x.MetadataId.Contains(rootComponent.ObjectId.ToString())).FirstOrDefault <EntityMetadataInfo>(); if (emdi != null) { var amdi = emdi.EntityMetadata.Attributes.Where(x => x.MetadataId == component.ObjectId).FirstOrDefault <AttributeMetadata>(); emdi.Attributes.Add(new AttributeMetadataInfo(amdi)); } } }
public void AddAttribute(CrmComponent component, CrmComponent rootComponent) { if (rootComponent != null) { var entityComp = EntityComponents.Components.Where(x => x.MetadataId.Contains(rootComponent.ObjectId.ToString())).FirstOrDefault <EntityComponent>(); if (entityComp != null) { var amd = entityComp.Meta.Attributes.Where(x => x.MetadataId == component.ObjectId).FirstOrDefault <AttributeMetadata>(); entityComp.Attributes.Add(new AttributeComponent(amd)); } } }
internal void AddManyToManyRelationship(CrmComponent component, CrmComponent rootComponent) { if (rootComponent != null) { var emdi = EntityMetas.Where(x => x.MetadataId.Contains(rootComponent.ObjectId.ToString())).FirstOrDefault <EntityMetadataInfo>(); if (emdi != null) { var mtmr = emdi.EntityMetadata.ManyToManyRelationships.Where(x => x.MetadataId == component.ObjectId).FirstOrDefault <ManyToManyRelationshipMetadata>(); if (mtmr != null) { emdi.ManyToManyRelationships.Add(new ManyToManyRelationshipMetadataInfo(mtmr)); } } } }
internal void AddManyToOneRelationship(CrmComponent component, CrmComponent rootComponent) { if (rootComponent != null) { var emdi = EntityMetas.Where(x => x.MetadataId.Contains(rootComponent.ObjectId.ToString())).FirstOrDefault <EntityMetadataInfo>(); if (emdi != null) { var otmr = emdi.EntityMetadata.ManyToOneRelationships.Where(x => x.MetadataId == component.ObjectId).FirstOrDefault <OneToManyRelationshipMetadata>(); if (otmr != null) { emdi.ManyToOneRelashionships.Add(new OneToManyRelationshipMetadataInfo(otmr)); var primaryEntity = EntityMetas.Where(x => x.LogicalName == otmr.ReferencedEntity).FirstOrDefault <EntityMetadataInfo>(); if (primaryEntity != null) { primaryEntity.OneToManyRelashionships.Add(new OneToManyRelationshipMetadataInfo(otmr)); } } } } }