private void GenerateModelClasses(Entity entity)
        {
            foreach (var model in entity.Models)
            {
                Options.Variables.Set("Model.Name", model.ModelClass);

                var directory = GetModelDirectory(model);
                var file      = model.ModelClass + ".cs";
                var path      = Path.Combine(directory, file);
                if (Options.Project.AddSchemaToNamespace && !string.IsNullOrEmpty(entity.TableSchema))
                {
                    path = Path.Combine(directory, entity.TableSchema, file);
                }

                _logger.LogInformation(File.Exists(path)
                    ? "Updating model class: {file}"
                    : "Creating model class: {file}", file);


                var template = new ModelClassTemplate(model, Options);
                template.WriteCode(path);
            }

            Options.Variables.Remove("Model.Name");
        }
Exemple #2
0
        public void GenerateModelCodeFile(string path, Dictionary <string, object> parameters)
        {
            ModelClassTemplate t = new ModelClassTemplate();

            t.Session = new System.Collections.Generic.Dictionary <string, object>();
            foreach (string parameterKey in parameters.Keys)
            {
                t.Session[parameterKey] = parameters[parameterKey];
            }
            t.Initialize();
            string content = t.TransformText();

            File.WriteAllText(path, content);
        }
Exemple #3
0
        private void GenerateModelClasses(Entity entity)
        {
            foreach (var model in entity.Models)
            {
                this.Options.Variables.Set("Model.Name", entity.EntityClass);

                var directory = this.GetModelDirectory(model);
                var file      = model.ModelClass + ".cs";
                var path      = Path.Combine(directory, file);

                this._logger.LogInformation(File.Exists(path)
                    ? $"Updating model class: {file}"
                    : $"Creating model class: {file}");

                var template = new ModelClassTemplate(model, this.Options);
                template.WriteCode(path);
            }

            this.Options.Variables.Remove("Model.Name");
        }
        private void GenerateModelClasses(Entity entity)
        {
            foreach (var model in entity.Models)
            {
                Options.Variables.Set(model);

                var directory = GetModelDirectory(model);
                var file      = model.ModelClass + ".cs";
                var path      = Path.Combine(directory, file);

                _logger.LogInformation(File.Exists(path)
                    ? "Updating model class: {file}"
                    : "Creating model class: {file}", file);


                var template = new ModelClassTemplate(model, Options);
                template.WriteCode(path);

                Options.Variables.Remove(model);
            }
        }