mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-04 04:37:58 +08:00
Update Demo
This commit is contained in:
parent
10b00dd801
commit
e91f9c8456
@ -8,5 +8,6 @@ namespace SugarCodeGeneration
|
|||||||
public string ConnectionString { get; set; }
|
public string ConnectionString { get; set; }
|
||||||
public DbType DbType { get; set; }
|
public DbType DbType { get; set; }
|
||||||
public List<string> Tables { get; set; }
|
public List<string> Tables { get; set; }
|
||||||
|
public string ClassNamespace { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,7 +45,7 @@ namespace SugarCodeGeneration
|
|||||||
var savePath = Methods.GetSlnPath + "\\" + contextProjectName + "\\" + contextPath + "\\DbContext.cs";//具体文件名
|
var savePath = Methods.GetSlnPath + "\\" + contextProjectName + "\\" + contextPath + "\\DbContext.cs";//具体文件名
|
||||||
var tables = db.DbMaintenance.GetTableInfoList().Select(it => it.Name).ToList();
|
var tables = db.DbMaintenance.GetTableInfoList().Select(it => it.Name).ToList();
|
||||||
//执行生成
|
//执行生成
|
||||||
GenerationDContext(contextProjectName, contextPath, savePath, tables);
|
GenerationDContext(contextProjectName, contextPath, savePath, tables, classNamespace);
|
||||||
Print("DbContext创建成功");
|
Print("DbContext创建成功");
|
||||||
|
|
||||||
|
|
||||||
@ -96,14 +96,15 @@ namespace SugarCodeGeneration
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成DbContext
|
/// 生成DbContext
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void GenerationDContext(string contextProjectName, string contextPath, string savePath,List<string> tables)
|
private static void GenerationDContext(string contextProjectName, string contextPath, string savePath,List<string> tables,string classNamespace)
|
||||||
{
|
{
|
||||||
var templatePath = Methods.GetCurrentProjectPath + "\\Template\\DbContext.txt";//dbcontexts模版文件
|
var templatePath = Methods.GetCurrentProjectPath + "\\Template\\DbContext.txt";//dbcontexts模版文件
|
||||||
//下面代码不动
|
//下面代码不动
|
||||||
var model = new DbContextParameter{
|
var model = new DbContextParameter{
|
||||||
ConnectionString = connectionString,
|
ConnectionString = connectionString,
|
||||||
DbType = dbType,
|
DbType = dbType,
|
||||||
Tables = tables
|
Tables = tables,
|
||||||
|
ClassNamespace= classNamespace
|
||||||
};
|
};
|
||||||
Methods.CreateDbContext(templatePath,savePath,model);
|
Methods.CreateDbContext(templatePath,savePath,model);
|
||||||
AddTask(contextProjectName,contextPath);
|
AddTask(contextProjectName,contextPath);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MyTest;
|
using @Model.ClassNamespace;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
Loading…
Reference in New Issue
Block a user