SmartCode(https://github.com/Ahoo-Wang/SmartCode)

SmartCode = IDataSource -> IBuildTask -> IOutput => Build Everything

Introduction

SmartCode.Generator (代码生成器)

Demo

Getting Started

  1. Install from .NET Core Global Tool
dotnet tool install --global SmartCode.CLI
  1. 编辑构建配置文件(默认:SmartCode.yml)
  2. 命令行执行SmartCode命令
    • SmartCode
    • 等待提示输入配置文件路径(可选:默认程序根目录下SmartCode.yml文件)
    • 回车执行命令
  3. 等待任务执行结束
  4. 查看输出目录结果

构建配置文件

Module: SmartSql.Starter
Author: Ahoo Wang
DataSource:
Name: Db
Paramters:
DbName: SmartSqlStarterDB
DbProvider: SqlServer
ConnectionString: Data Source=.;Initial Catalog=SmartSqlStarterDB;Integrated Security=True
Language: CSharp
TemplateEngine: Razor
Output:
Type: File
Path: 'E://SmartSql-Starter' # 构建任务
Build:
ClearDir:
Type: Clear
Paramters:
Dirs: '.'
Solution:
Type: Project
Template: Sln.cshtml
Output:
Path: '.'
Name: '{{Project.Module}}'
Extension: '.sln'
SmartSqlConfig:
Type: Project
Template: SqlMapConfig.cshtml
Output:
Path: '{{Project.Module}}.API'
Name: 'SmartSqlMapConfig'
Extension: '.xml'
Entity_Project:
Type: Project
Template: Proj.cshtml
Output:
Path: '{{Project.Module}}.Entity'
Name: '{{Project.Module}}.Entity'
Extension: '.csproj'
Entity:
Type: Table
Module: Entity
Template: Entity.cshtml
Output:
Path: '{{Project.Module}}.{{Build.Module}}'
Extension: '.cs'
NamingConverter:
Table:
Tokenizer:
Type: Default
Paramters:
IgnorePrefix: 'T_'
Delimiter: '_'
Converter:
Type: Default
Paramters: { }
View:
Tokenizer:
Type: Default
Paramters:
IgnorePrefix: 'V_'
Delimiter: '_'
Converter:
Type: Pascal
Column:
Tokenizer:
Type: Default
Paramters:
Delimiter: '_'
Converter:
Type: Pascal
Repository_Project:
Type: Project
Template: Proj-Repository.cshtml
Output:
Path: '{{Project.Module}}.Repository'
Name: '{{Project.Module}}.Repository'
Extension: '.csproj'
Repository:
Type: Table
Module: Repository
Template: Repository.cshtml
Output:
Path: '{{Project.Module}}.{{Build.Module}}'
Name: 'I{{OutputName}}Repository'
Extension: .cs
NamingConverter:
Table:
Tokenizer:
Type: Default
Paramters:
IgnorePrefix: 'T_'
Delimiter: '_'
Converter:
Type: Default
View:
Tokenizer:
Type: Default
Paramters:
IgnorePrefix: 'V_'
Delimiter: '_'
Converter:
Type: Default SqlMap:
Type: Table
Template: SqlMap-SqlServer.cshtml
Output:
Path: '{{Project.Module}}.API/Maps'
Extension: .xml
IgnoreTables: null
NamingConverter:
Table:
Tokenizer:
Type: Default
Paramters:
IgnorePrefix: 'T_'
Delimiter: '_'
Converter:
Type: Default
View:
Tokenizer:
Type: Default
Paramters:
IgnorePrefix: 'V_'
Delimiter: '_'
Converter:
Type: Default
Column:
Tokenizer:
Type: Default
Paramters:
IgnorePrefix: 'T_'
Delimiter: '_'
Converter:
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

如何贡献模板

为了让更多人参与到SmartCode模板建设中来,故有以下模板规范:

  1. 模板作者在 src/SmartCode.Generator/RazorTemplates 中新建目录,并以作者英文名为目录名称
  2. 把模板放置到作者目录
  3. 作者目录下必须包括 README.md 文件,以说明模板的用途场景以及使用方式
  4. 提交PR

SmartCode.ETL(Extract-Transform-Load)

ETL 构建配置

Author: Ahoo Wang
DataSource:
Name: Extract
Paramters:
DbProvider: SqlServer
ConnectionString: Data Source=.;Initial Catalog=SmartSqlDB;Integrated Security=True
Query: SELECT [Id],[UserName],[Pwd],[Status],[LastLoginTime],[CreationTime],[Deleted] FROM [T_User] Where Id>@LastMaxId And CreationTime>@LastQueryTime
PKColumn: Id Paramters:
ETLCode: SmartCode.ETL.Test
ETLRepository: PG Build: Transform:
Type: Transform
Paramters:
Script: Load2PostgreSql.cshtml Load2PostgreSql:
Type: Load
Paramters:
DbProvider: PostgreSql
ConnectionString: Server=localhost;Port=5432;User Id=postgres;Password=SmartSql; Database=smartsql_db;
Table: t_user
ColumnMapping: [{Column: UserName,Mapping: user_name}
,{Column: Pwd,Mapping: pwd}
,{Column: Status,Mapping: status}
,{Column: LastLoginTime,Mapping: lastlogintime}
,{Column: CreationTime,Mapping: creationtime}
,{Column: Deleted,Mapping: deleted}]
PreCommand:
PostCommand:

作者:Ahoo Wang (阿虎)

Github: https://github.com/Ahoo-Wang/

SmartSql(高性能、高生产力,超轻量级的ORM!): https://github.com/dotnetcore/SmartSql

SmartCode(不只是代码生成器!): https://github.com/dotnetcore/SmartCode


本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

SmartCode的更多相关文章

  1. ASP.NET MVC 5 SmartCode Scaffolding for Visual Studio.Net

    介绍 ASP.NET MVC 5 SmartCode Scaffolding是集成在Visual Studio.Net开发工具中一个ASP.NET MVC Web应用程序代码生成框架,使用SmartC ...

  2. SmartCode.ETL 这不是先有鸡还是蛋的问题!

    继国庆节 SmartCode 正式版(SmartCode.Generator)发布之后,SmartCode 迎来了新的能力 SmartCode.ETL ! SmartCode 正式版从开始发布就从未说 ...

  3. SmartCode 使用常见问题

    SmartCode 常见问题 SmartCode 能干什么? SmartCode = IDataSource -> IBuildTask -> IOutput => Build Ev ...

  4. SmartCode 正式开源,不只是代码生成器!

    SmartCode(https://github.com/Ahoo-Wang/SmartCode) SmartCode = IDataSource -> IBuildTask -> IOu ...

  5. asp.net资料! (.NET) (ASP.NET)

    使用SqlBulkCopy类加载其他源数据到SQL表 在数据回发时,维护ASP.NET Tree控件的位置 vagerent的vs2005网站开发技巧 ASP.NET2.0小技巧--内部控件权限的实现 ...

  6. allVncClients

    VNC Viewer Free Edition 37  RealVNC Ltd.  15,367  Freeware  1021.58 KB VNC is client and server remo ...

  7. 你必须知道的 SmartSql !

    介绍 SmartSql = MyBatis + Cache(Memory | Redis) + R/W Splitting +Dynamic Repository + Diagnostics .... ...

  8. SmartSql 介绍

    介绍 SmartSql = MyBatis + Cache(Memory | Redis) + R/W Splitting +Dynamic Repository + Diagnostics .... ...

  9. SmartSql 常见问题

    常见问题 为什么不支持 Linq? SmartSql 希望 开发人员更多的接触 Sql ,获得绝对的控制权与安全感.所以目前没有计划支持 Code First 编程模式. 我想好了Sql怎么写,然后再 ...

随机推荐

  1. c语言二级指针的使用,malloc内存申请

    #include<stdio.h> #include<stdlib.h> void AllocateMemory(int **pGetMemory, int n) { int ...

  2. 如何学好java?

    忻州seo:如何学好java?想必对于任何一个在学习java的朋友们,都会在学习过程中遇到一些问题.例如:Java反射机制是什么?小编也是学习java编程的,现在给大家简单介绍一下:Java反射机制就 ...

  3. unsafe包的学习和使用

    Go语言之unsafe包介绍及使用 unsafe内容介绍 type ArbitraryType int type Pointer *ArbitraryType func Sizeof(x Arbitr ...

  4. Postgresql vacuum freeze相关参数

    先看3个参数:autovacuum_freeze_max_age           | 500000vacuum_freeze_min_age               | 10vacuum_fr ...

  5. Ubuntu18.04开机动画(bootsplash)安装

    一.搜索喜欢的主题 1.通过软件源搜索,这个比较简单但是没有太喜欢的.-----------------------------------------------------------pipci@ ...

  6. Bzoj 2733: [HNOI2012]永无乡(线段树+启发式合并)

    2733: [HNOI2012]永无乡 Time Limit: 10 Sec Memory Limit: 128 MB Description 永无乡包含 n 座岛,编号从 1 到 n,每座岛都有自己 ...

  7. 安装less/sass

    安装sass npm i node-sass 安装wepy-compiler-sass插件 npm install wepy-compiler-sass --save-dev 在我的项目中使用才有用.

  8. 控制层@Value注解取不到值

    @Value("${enable-upload-image}") private String enable; 如上所示,同样的代码,写在在业务层,运行时能取到正确的值,但在控制层 ...

  9. codeforces193B

    CF193B Xor sol:发现好像非常不可做的样子,发现n,u都很小,大胆dfs,因为异或偶数次毫无卵用,只要判每次是否做2操作就是了,复杂度O(可过) #include <bits/std ...

  10. P5346 【XR-1】柯南家族(后缀数组+主席树)

    题目 P5346 [XR-1]柯南家族 做法 聪明性是具有传递性的,且排列是固定的 那么先预处理出每个点的名次,用主席树维护\(k\)大值 一眼平衡树,遍历的同时插入\(O(log^2n)\),总时间 ...