コード例 #1
0
 public CdmEntityGenerator(CdmCorpusDefinition corpus, CdmReferenceResolver resolver, CdmDocumentDefinition entityDocument, string version)
 {
     this.corpus         = corpus;
     this.resolver       = resolver;
     this.entityDocument = entityDocument;
     this.version        = version;
 }
コード例 #2
0
        public async Task <CdmManifestDefinition> GenerateCdmAsync(RelationalModel model)
        {
            CdmCorpusDefinition  corpus   = new CdmCorpusDefinition();
            CdmReferenceResolver resolver = new CdmReferenceResolver(options.ManifestName, options.EntitiesVersion);

            var outputManifestFile = Path.Combine(Path.GetFullPath(options.OutputFolder), resolver.GetManifestFileName());

            if (File.Exists(outputManifestFile))
            {
                if (options.OverrideExistingManifest)
                {
                    File.Delete(outputManifestFile);
                }
                else
                {
                    throw new Exception($"Manifest {outputManifestFile} already exists. Please use the override option.");
                }
            }

            CdmFolderDefinition folder = corpus.GetLocalRootFolder(options.OutputFolder);

            CdmManifestDefinition manifest = corpus.CreateCdmManifest(resolver.GetManifestName());

            folder.Documents.Add(manifest);

            foreach (var table in model.Tables)
            {
                string documentName = resolver.GetDocumentFileName(table.Name);
                CdmDocumentDefinition entityDocument = corpus.CreateCdmDocument(documentName);
                folder.Documents.Add(entityDocument);

                var entityGenerator        = new CdmEntityGenerator(corpus, resolver, entityDocument, options.EntitiesVersion);
                CdmEntityDefinition entity = entityGenerator.GenerateEntity(table);
                manifest.Entities.Add(entity);

                var relationshipGenerator = new CdmEntityRelationshipGenerator(corpus, resolver);
                IEnumerable <CdmE2ERelationship> relationships = relationshipGenerator.GenerateRelationships(table);
                manifest.Relationships.AddRange(relationships);
            }

            if (options.HasTimestamps)
            {
                await manifest.FileStatusCheckAsync();
            }

            if (options.HasVirtualPartition)
            {
                CreateVirtualPartitionOnEntities(corpus, manifest);
            }

            return(manifest);
        }
コード例 #3
0
 public CdmEntityRelationshipGenerator(CdmCorpusDefinition corpus, CdmReferenceResolver resolver)
 {
     this.corpus   = corpus;
     this.resolver = resolver;
 }