GenerateFiles() public method

public GenerateFiles ( IEnumerable maps, DatabaseSchema schema, string domainNamespace, IAnswerProvider answerProvider ) : string>.IDictionary
maps IEnumerable
schema DatabaseSchema
domainNamespace string
answerProvider IAnswerProvider
return string>.IDictionary
Exemplo n.º 1
0
 public void CollectionColumnInitStatementAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("this.Comments = new List<Comment>();", results["Post"]);
 }
Exemplo n.º 2
0
 public void ParentColumnAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("public Blog Blog { get; set; }", results["Post"]);
 }
Exemplo n.º 3
0
 public void NamespaceAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("namespace " + TestNamespace, results.First().Value);
 }
Exemplo n.º 4
0
 public void PrimaryKeyAdded() {
     var generator = new ModelGenerator();
     var config = new CustomConfig();
     var results = generator.GenerateFiles(config.Maps, this.MakeSchema(config), TestNamespace, null);
     Assert.Contains("public System.Int32 PostId { get; set; }", results["Post"]);
 }
Exemplo n.º 5
0
        private static void DoReverseEngineer(
            CommandLineOptions options,
            DashingSettings dashingSettings,
            ReverseEngineerSettings reverseEngineerSettings,
            ConnectionStringSettings connectionString) {
            // overwrite the path with the default if necessary
            if (string.IsNullOrEmpty(options.Location)) {
                options.Location = dashingSettings.DefaultSavePath;
            }

            // if it is still empty, ...
            if (string.IsNullOrEmpty(options.Location) && options.ReverseEngineer) {
                throw new CatchyException("You must specify a location for generated files to be saved");
            }

            // require a generated namespace
            if (string.IsNullOrEmpty(reverseEngineerSettings.GeneratedNamespace)) {
                throw new CatchyException("You must specify a GeneratedNamespace in the Project ini file");
            }

            DatabaseSchema schema;
            var engineer = new Engineer(reverseEngineerSettings.ExtraPluralizationWords);

            var databaseReader = new DatabaseReader(connectionString.ConnectionString, connectionString.ProviderName);
            schema = databaseReader.ReadAll();
            var maps = engineer.ReverseEngineer(
                schema,
                new DialectFactory().Create(connectionString.ToSystem()),
                reverseEngineerSettings.GetTablesToIgnore(),
                consoleAnswerProvider,
                true);
            var reverseEngineer = new ModelGenerator();
            var sources = reverseEngineer.GenerateFiles(maps, schema, reverseEngineerSettings.GeneratedNamespace, consoleAnswerProvider);

            foreach (var source in sources) {
                File.WriteAllText(options.Location + "\\" + source.Key + ".cs", source.Value);
            }
        }