Example #1
0
        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));
                }
            }
        }
Example #2
0
        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));
                    }
                }
            }
        }
Example #3
0
        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));
                        }
                    }
                }
            }
        }