示例#1
0
 private void lbExistingMappings_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (lbExistingMappings.SelectedItem != null)
     {
         SDK.RelationMapping           relMapping  = ((ListBoxItem)lbExistingMappings.SelectedItem).Tag as SDK.RelationMapping;
         OneToManyRelationshipMetadata relMetadata = relationsMetadata.Where(t => t.ReferencingAttribute == relMapping.LogicalName && t.ReferencedEntity == relMapping.EntityName).First();
         SetRelationChosen(relMetadata);
     }
 }
        void bgwRelationKeyMappingWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            OneToManyRelationshipMetadata relationMetadata = ((object[])e.Result)[0] as OneToManyRelationshipMetadata;
            EntityMetadata entityMetadata = ((object[])e.Result)[1] as EntityMetadata;

            SDK.RelationMapping relationMapping = Configuration.RelationMapping.Where(t => t.LogicalName == relationMetadata.ReferencingAttribute && t.EntityName == relationMetadata.ReferencedEntity).FirstOrDefault();
            if (relationMapping == null)
            {
                relationMapping = new SDK.RelationMapping()
                {
                    LogicalName = relationMetadata.ReferencingAttribute, EntityName = relationMetadata.ReferencedEntity
                };
                Configuration.RelationMapping.Add(relationMapping);
            }

            List <NameDisplayName> sourceList = this.dataObject.Metadata.GetColumnsAsNameDisplayNameList();
            List <NameDisplayName> targetList = Crm2013Wrapper.Crm2013Wrapper.GetAllAttributesOfEntity(entityMetadata);

            Relation.RelationMappingKeyMapping relationMappingKeyMapping = new Relation.RelationMappingKeyMapping(relationMapping, sourceList, targetList);
            relationMappingKeyMapping.DeleteRelationMapping += relationMappingKeyMapping_DeleteRelationMapping;
            RelationMappingContent.Content = RelationMappingContent.Content = relationMappingKeyMapping;
        }