Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartCode 常见问题 #7

Open
Ahoo-Wang opened this issue Oct 20, 2018 · 0 comments
Open

SmartCode 常见问题 #7

Ahoo-Wang opened this issue Oct 20, 2018 · 0 comments
Labels

Comments

@Ahoo-Wang
Copy link
Member

Ahoo-Wang commented Oct 20, 2018

SmartCode 常见问题

SmartCode 能干什么?

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

SmartCode的执行流是 数据源->构建任务->输出,也就是说应用场景非常广泛。

  1. 从DB读取数据结构,最终生成整个解决方案=代码生成器(SmartCode.Generator)
  2. ETL,其实很显然SmartCode执行流跟ETL很像,做一些相应的扩展便可支持ETL(SmartCode.ETL)
  3. Mode First,从Model类结构解析出数据源,最终生成SQL脚本,执行生成DB结构,并生成整个解决方案
  4. 静态文档生成器
  5. 还有很多等待你去发掘

SmartCode 扩展性如何

SmartCode 插件机制拥有非常灵活的扩展能力,SmartCode 中一切都是插件。只要继承IPlugin接口即可,然后配置到appsettings.json,然后通过IPluginManager获取插件实例。

{
  "Logging": {
    "IncludeScopes": false,
    "Console": {
      "LogLevel": {
        "Default": "Debug"
      }
    }
  },
  "SmartCode": {
    "Version": "v1.7.0",
    "Plugins": [
      {
        "Type": "SmartCode.IDataSource,SmartCode",
        "ImplType": "SmartCode.Db.DbSource,SmartCode.Db"
      },
      {
        "Type": "SmartCode.IBuildTask,SmartCode",
        "ImplType": "SmartCode.App.BuildTasks.ClearBuildTask,SmartCode.App"
      },
      {
        "Type": "SmartCode.IBuildTask,SmartCode",
        "ImplType": "SmartCode.App.BuildTasks.MultiTemplateBuildTask,SmartCode.App"
      },
      {
        "Type": "SmartCode.IBuildTask,SmartCode",
        "ImplType": "SmartCode.Db.BuildTasks.BuildTask,SmartCode.Db"
      },
      {
        "Type": "SmartCode.IBuildTask,SmartCode",
        "ImplType": "SmartCode.Db.BuildTasks.ProjectBuildTask,SmartCode.Db"
      },
      {
        "Type": "SmartCode.IOutput,SmartCode",
        "ImplType": "SmartCode.App.Outputs.FileOutput,SmartCode.App"
      },
      {
        "Type": "SmartCode.INamingConverter,SmartCode",
        "ImplType": "SmartCode.Db.TableNamingConverter,SmartCode.Db"
      },
      {
        "Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
        "ImplType": "SmartCode.TemplateEngine.Impl.HandlebarsTemplateEngine,SmartCode.TemplateEngine"
      },
      {
        "Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
        "ImplType": "SmartCode.TemplateEngine.Impl.OfficialRazorTemplateEngine,SmartCode.TemplateEngine"
      },
      {
        "Type": "SmartCode.Db.IDbTypeConverter,SmartCode.Db",
        "ImplType": "SmartCode.Db.DbTypeConverter.DefaultDbTypeConverter,SmartCode.Db"
      }
    ]
  }
}

如何自定义模板

目前SmartCode支持俩种模板引擎 Razor & Handlebars
Razor 模板引擎使用的是官方版本,这一点上.NETer同学可以很轻松的自定义SmartCode模板,需要注意的是Razor模板的Model为BuildContext,具体方法可以参考源代码中的模板。编写完成之后放到RazorTemplates,构建时指定好即可。

代码生成器支持多少种数据库

SmartCode获取数据源结构使用的是SmartSql,所以SmartCode支持所有ADO.NET驱动相关的数据库:MySql/PostgreSql/SqlServer/Oracle/SQLite 等

@Ahoo-Wang Ahoo-Wang added question Further information is requested notice and removed question Further information is requested labels Oct 20, 2018
@Ahoo-Wang Ahoo-Wang pinned this issue Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant