SmartCode(https://github.com/Ahoo-Wang/SmartCode)
SmartCode = IDataSource -> IBuildTask -> IOutput => Build Everything
Introduction

SmartCode.Db (代码生成器)
Demo

Getting Started
-
Install from .NET Core Global Tool
dotnet tool install --global SmartCode.CLI
-
编辑构建配置文件(默认:SmartCode.yml)
-
命令行执行SmartCode命令
- SmartCode
- 等待提示输入配置文件路径(可选:默认程序根目录下SmartCode.yml文件)
- 回车执行命令
-
等待任务执行结束
-
查看输出目录结果
构建配置文件
1Module: SmartSql.Starter 2Author: Ahoo Wang 3DataSource: 4 Name: Db 5 Paramters: 6 DbName: SmartSqlStarterDB 7 DbProvider: SqlServer 8 ConnectionString: Data Source=.;Initial Catalog=SmartSqlStarterDB;Integrated Security=True 9Language: CSharp 10TemplateEngine: Razor 11Output: 12 Type: File 13 Path: 'E://SmartSql-Starter' 14 15# 构建任务 16Build: 17 ClearDir: 18 Type: Clear 19 Paramters: 20 Dirs: '.' 21 Solution: 22 Type: Project 23 Template: Sln.cshtml 24 Output: 25 Path: '.' 26 Name: '{{Project.Module}}' 27 Extension: '.sln' 28 SmartSqlConfig: 29 Type: Project 30 Template: SqlMapConfig.cshtml 31 Output: 32 Path: '{{Project.Module}}.API' 33 Name: 'SmartSqlMapConfig' 34 Extension: '.xml' 35 Entity_Project: 36 Type: Project 37 Template: Proj.cshtml 38 Output: 39 Path: '{{Project.Module}}.Entity' 40 Name: '{{Project.Module}}.Entity' 41 Extension: '.csproj' 42 Entity: 43 Type: Table 44 Module: Entity 45 Template: Entity.cshtml 46 Output: 47 Path: '{{Project.Module}}.{{Build.Module}}' 48 Extension: '.cs' 49 NamingConverter: 50 Table: 51 Tokenizer: 52 Type: Default 53 Paramters: 54 IgnorePrefix: 'T_' 55 Delimiter: '_' 56 Converter: 57 Type: Default 58 Paramters: { } 59 View: 60 Tokenizer: 61 Type: Default 62 Paramters: 63 IgnorePrefix: 'V_' 64 Delimiter: '_' 65 Converter: 66 Type: Pascal 67 Column: 68 Tokenizer: 69 Type: Default 70 Paramters: 71 Delimiter: '_' 72 Converter: 73 Type: Pascal 74 Repository_Project: 75 Type: Project 76 Template: Proj-Repository.cshtml 77 Output: 78 Path: '{{Project.Module}}.Repository' 79 Name: '{{Project.Module}}.Repository' 80 Extension: '.csproj' 81 Repository: 82 Type: Table 83 Module: Repository 84 Template: Repository.cshtml 85 Output: 86 Path: '{{Project.Module}}.{{Build.Module}}' 87 Name: 'I{{OutputName}}Repository' 88 Extension: .cs 89 NamingConverter: 90 Table: 91 Tokenizer: 92 Type: Default 93 Paramters: 94 IgnorePrefix: 'T_' 95 Delimiter: '_' 96 Converter: 97 Type: Default 98 View: 99 Tokenizer: 100 Type: Default 101 Paramters: 102 IgnorePrefix: 'V_' 103 Delimiter: '_' 104 Converter: 105 Type: Default 106 107 SqlMap: 108 Type: Table 109 Template: SqlMap-SqlServer.cshtml 110 Output: 111 Path: '{{Project.Module}}.API/Maps' 112 Extension: .xml 113 IgnoreTables: null 114 NamingConverter: 115 Table: 116 Tokenizer: 117 Type: Default 118 Paramters: 119 IgnorePrefix: 'T_' 120 Delimiter: '_' 121 Converter: 122 Type: Default 123 View: 124 Tokenizer: 125 Type: Default 126 Paramters: 127 IgnorePrefix: 'V_' 128 Delimiter: '_' 129 Converter: 130 Type: Default 131 Column: 132 Tokenizer: 133 Type: Default 134 Paramters: 135 IgnorePrefix: 'T_' 136 Delimiter: '_' 137 Converter: 138 Type: Default
参数名
说明
Module
根模块名
Author
作者
DataSource
数据源
Language
语言:CSharp/Java/....
TemplateEngine
模板引擎:目前内置:Razor/Handlebars
Output
输出
Build
任务构建s
DataSource 数据源,Name:Db
属性 Name:Db,使用DbSource插件作为数据源
DbSource.Paramters 接受以下三个参数:
参数名
说明
DbName
数据库名称
DbProvider
数据驱动提供者:MySql,MariaDB,PostgreSql,SqlServer,Oracle,SQLite
ConnectionString
连接字符串
Build 任务构建
参数名
说明
Type
构建类型,Clear:用于清理目录s/文件s,Project:用于构建单文件,如:解决方案文件/项目文件,Table: 用于构建以数据表为基础的文件,如:Entity,Repository文件
Module
构建模块名
TemplateEngine
模板引擎,可选,默认使用根模块引擎
Template
模板文件
Output
输出
IncludeTables
包括表名s
IgnoreTables
忽略表名s
NamingConverter
命名转换器
Paramters
自定义构建参数
NamingConverter 命名转换
属性
说明
类型
Table/View/Column
Tokenizer
分词器
Converter
转换器:Camel/Pascal/None
NamingConverter.Tokenizer 分词器
属性
说明
Type
Default
Paramters.IgnorePrefix
忽略前缀字符
Paramters.Delimiter
分隔符
Paramters.UppercaseSplit
使用大写分隔,默认:true
