コード例 #1
0
        private string DoGenerateEntity(GenerateCodeTypeTreeNavigationItem generateCodeTypeTreeNavigationItem)
        {
            EntityClassTemplate entityClassTemplate = new EntityClassTemplate();

            entityClassTemplate.Session = new Dictionary <string, object>();
            entityClassTemplate.Session.Add("_classStructure", CreateClassStructure(generateCodeTypeTreeNavigationItem));
            entityClassTemplate.Initialize();
            return(entityClassTemplate.TransformText());
        }
コード例 #2
0
        private void GenerateEntityClasses(EntityContext entityContext)
        {
            foreach (var entity in entityContext.Entities)
            {
                Options.Variables.Set("Entity.Name", entity.EntityClass);

                var directory = Options.Data.Entity.Directory;
                var file      = entity.EntityClass + ".cs";
                var path      = Path.Combine(directory, file);

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

                var template = new EntityClassTemplate(entity, Options);
                template.WriteCode(path);
            }

            Options.Variables.Remove("Entity.Name");
        }
コード例 #3
0
        private void GenerateEntityClasses(EntityContext entityContext)
        {
            foreach (var entity in entityContext.Entities)
            {
                Options.Variables.Set("Entity.Name", entity.EntityClass);

                var directory = Options.Data.Entity.Directory;
                var file      = entity.EntityClass + ".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 entity class: {file}"
                    : "Creating entity class: {file}", file);

                var template = new EntityClassTemplate(entity, Options);
                template.WriteCode(path);
            }

            Options.Variables.Remove("Entity.Name");
        }