Example #1
0
        private static List <RelationshipEntity> CreateRelationships(CdmManifestDefinition instance, IDictionary <string, RelationshipEntity> existingRelationshipEntities,
                                                                     ResolveOptions resOpt, CopyOptions options)
        {
            var relationships = new Dictionary <string, RelationshipEntity>();

            if (instance.Relationships != null && instance.Relationships.Count > 0)
            {
                foreach (var cdmRelationship in instance.Relationships)
                {
                    if (Utils.IsRelationshipAddedorModified(cdmRelationship, existingRelationshipEntities))
                    {
                        if (!relationships.ContainsKey(instance.Name))
                        {
                            var relationship = E2ERelationshipPersistence.ToData(cdmRelationship, instance.ManifestName, resOpt, options);
                            if (relationship != null)
                            {
                                relationships[relationship.Name] = relationship;
                            }
                            else
                            {
                                Logger.Error((ResolveContext)instance.Ctx, Tag, nameof(ToDataAsync), instance.AtCorpusPath, CdmLogCode.ErrPersistModelJsonRelConversionError);
                            }
                        }
                        else
                        {
                            var relationshipEntity = relationships[instance.Name];
                            ((RelationshipProperties)relationshipEntity.Properties).ColumnRelationshipInformations.Add(new ColumnRelationshipInformation(cdmRelationship.FromEntityAttribute, cdmRelationship.ToEntityAttribute));
                        }
                    }
                }
            }

            return(relationships.Values.ToList());
        }