Browse Source

Update Demo

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
e91f9c8456
  1. 1
      Src/Asp.Net/SugarCodeGeneration/Codes/DbContextParameter.cs
  2. 7
      Src/Asp.Net/SugarCodeGeneration/Program.cs
  3. 2
      Src/Asp.Net/SugarCodeGeneration/Template/DbContext.txt

1
Src/Asp.Net/SugarCodeGeneration/Codes/DbContextParameter.cs

@ -8,5 +8,6 @@ namespace SugarCodeGeneration
public string ConnectionString { get; set; }
public DbType DbType { get; set; }
public List<string> Tables { get; set; }
public string ClassNamespace { get; set; }
}
}

7
Src/Asp.Net/SugarCodeGeneration/Program.cs

@ -45,7 +45,7 @@ namespace SugarCodeGeneration
var savePath = Methods.GetSlnPath + "\\" + contextProjectName + "\\" + contextPath + "\\DbContext.cs";//具体文件名
var tables = db.DbMaintenance.GetTableInfoList().Select(it => it.Name).ToList();
//执行生成
GenerationDContext(contextProjectName, contextPath, savePath, tables);
GenerationDContext(contextProjectName, contextPath, savePath, tables, classNamespace);
Print("DbContext创建成功");
@ -96,14 +96,15 @@ namespace SugarCodeGeneration
/// <summary>
/// 生成DbContext
/// </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 model = new DbContextParameter{
ConnectionString = connectionString,
DbType = dbType,
Tables = tables
Tables = tables,
ClassNamespace= classNamespace
};
Methods.CreateDbContext(templatePath,savePath,model);
AddTask(contextProjectName,contextPath);

2
Src/Asp.Net/SugarCodeGeneration/Template/DbContext.txt

@ -1,4 +1,4 @@
using MyTest;
using @Model.ClassNamespace;
using SqlSugar;
using System;
using System.Collections.Generic;

Loading…
Cancel
Save