mirror of
https://github.com/anjoy8/Blog.Core.git
synced 2025-02-08 02:39:26 +08:00
Created Framework (markdown)
parent
c4e6df8e8d
commit
c955f85be5
58
Framework.md
Normal file
58
Framework.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
# 生成整体框架多层类文件
|
||||
|
||||
项目开发后期,如果添加了一个表,但是需要生成四个层文件,比较麻烦,我根据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)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user