Skip to content

Framework

ansonzhang edited this page Oct 15, 2019 · 1 revision

生成整体框架多层类文件

项目开发后期,如果添加了一个表,但是需要生成四个层文件,比较麻烦,我根据SQL sugar相关内容,写了一个自动生成的方法。

注意:相关代码是 netcore 3.0分支的

上下文与操作类

Blog.Core.Model/Seed/MyContext.cs

Blog.Core.Model/Seed/FrameSeed.cs(可自定义文件生成路径)

依赖注入上下文

services.AddScoped<Blog.Core.Model.Models.MyContext>();

如何使用

Blog.Core/Controller/DbFirst/DbFirstController.cs

 private readonly MyContext myContext;

 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="myContext"></param>
 public DbFirstController(MyContext myContext)
 {
     this.myContext = myContext;
 }

 /// <summary>
 /// 获取 整体框架 文件
 /// </summary>
 /// <returns></returns>
 [HttpGet]
 public bool GetFrameFiles()
 {
     return FrameSeed.CreateModels(myContext)
         && FrameSeed.CreateIRepositorys(myContext)
         && FrameSeed.CreateIServices(myContext)
         && FrameSeed.CreateRepository(myContext)
         && FrameSeed.CreateServices(myContext)
         ;
 }



入门指南

前端项目

交流与反馈

  • FAQ page is a good place to see whether your question is already asked.
  • Ask a question in cnblogs if you need help.
  • Submit an issue if you found a bug or have a feature request.
  • Open a pull request when you prepared to contribute. Before that, it is encouraged to open an issue to discuss.

更新日志

Clone this wiki locally