private void GenerateMappingClasses(EntityContext entityContext) { if (!Options.Data.Mapping.Generate) { return; } foreach (var entity in entityContext.Entities) { Options.Variables.Set(entity); var directory = Options.Data.Mapping.Directory; var file = entity.MappingClass + ".cs"; var path = Path.Combine(directory, file); _logger.LogInformation(File.Exists(path) ? "Updating mapping class: {file}" : "Creating mapping class: {file}", file); var template = new MappingClassTemplate(entity, Options); template.WriteCode(path); Options.Variables.Remove(entity); } }
private void GenerateMappingClasses(EntityContext entityContext) { foreach (var entity in entityContext.Entities) { var directory = this.Options.Data.Mapping.Directory; var file = entity.MappingClass + ".cs"; var path = Path.Combine(directory, file); this._logger.LogInformation(File.Exists(path) ? $"Updating mapping class: {file}" : $"Creating mapping class: {file}"); var template = new MappingClassTemplate(entity, this.Options); template.WriteCode(path); } }
private void GenerateMappingClasses(EntityContext entityContext) { foreach (var entity in entityContext.Entities) { Options.Variables.Set("Entity.Name", entity.EntityClass); var directory = Options.Data.Mapping.Directory; var file = entity.MappingClass + ".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 mapping class: {file}" : "Creating mapping class: {file}", file); var template = new MappingClassTemplate(entity, Options); template.WriteCode(path); } Options.Variables.Remove("Entity.Name"); }