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. go if for while 的使用

    fileName := "a.txt"contents ,err := ioutil.ReadFile(fileName) if err != nil{ fmt.Println(& ...

  2. 34、[源码]-AOP原理-链式调用通知方法

    34.[源码]-AOP原理-链式调用通知方法

  3. post提交主订单数据(gateway)实现httpapi

    models.proto syntax = "proto3"; package services; import "google/protobuf/timestamp.p ...

  4. Python获取百度浏览记录

    Python模拟百度登录实例详解 http://www.jb51.net/article/78406.htm Python实战计划学习作业2-1 http://blog.csdn.net/python ...

  5. git 文件名大小写不敏感

    1. 通过修改 git 配置: git config core.ignorecase false 2. 强制执行修改文件名命令: 需要重命名已添加到git的文件时,git mv --f oldFile ...

  6. CSP初赛复习

    初赛复习 初赛一定要过啊,否则付出的那么多都白搭了! while(1) ++csp.rp,++csp.luck,++csp.scores; 历史 2020年开始,除NOIP以外的NOI系列其他赛事(包 ...

  7. codeforces425C

    http://codeforces.com/contest/425/problem/C 题意:两数列a[],b[],进行若干轮操作,每次操作花费e, 将a的一个前缀和b的一个前缀(两前缀的最后一个数字 ...

  8. Tkinter 之MessageBox弹出框

    一.参数说明 语法 作用 截图 tk.messagebox.showwarning(title='提示', message='你确定要删除吗?') 警告信息弹窗   tk.messagebox.sho ...

  9. dubbo zookeeper图解入门配置

    这次主要是对dubbo 和zookeeper的配置做个记录,以便以后自己忘记了,或者踩的坑再次被踩 快速阅读 zookeerer类似 springcloud中的Eureka都做为注册中心,用srpin ...

  10. GitHub发卡系统zfaka配置历程

    GitHub发卡系统zfaka配置历程 1项目介绍 ​ ZFAKA发卡系统(本系统基于yaf+layui开发) ​ 项目地址 https://github.com/zlkbdotnet/zfaka 我 ...