mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 18:48:09 +08:00
Update Demo
This commit is contained in:
@@ -33,6 +33,28 @@ namespace SugarCodeGeneration.Codes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddRef(string projectName, string refProjectName)
|
||||||
|
{
|
||||||
|
|
||||||
|
var xmlPath = GetSlnPath + @"\" + projectName + @"\" + projectName + ".csproj";
|
||||||
|
|
||||||
|
var xml = File.ReadAllText(xmlPath, System.Text.Encoding.UTF8);
|
||||||
|
if (xml.Contains(refProjectName)) return;
|
||||||
|
var firstLine = System.IO.File.ReadLines(xmlPath, System.Text.Encoding.UTF8).First();
|
||||||
|
var newXml = xml.Replace(firstLine, "").TrimStart('\r').TrimStart('\n');
|
||||||
|
XDocument xe = XDocument.Load(xmlPath);
|
||||||
|
var root = xe.Root;
|
||||||
|
|
||||||
|
XElement itemGroup = new XElement("ItemGroup");
|
||||||
|
itemGroup.Add(new XElement("Name", refProjectName));
|
||||||
|
itemGroup.Add(new XElement("ProjectReference", new XAttribute("Include", string.Format(@"..\{0}\{0}.csproj", refProjectName))));
|
||||||
|
root.Add(itemGroup);
|
||||||
|
|
||||||
|
newXml = xe.ToString().Replace("xmlns=\"\"", "");
|
||||||
|
xe = XDocument.Parse(newXml);
|
||||||
|
xe.Save(xmlPath);
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddCsproj(string classPath, string projectName)
|
public static void AddCsproj(string classPath, string projectName)
|
||||||
{
|
{
|
||||||
CreateProject(projectName);
|
CreateProject(projectName);
|
||||||
|
@@ -12,7 +12,7 @@ namespace SugarCodeGeneration
|
|||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
//数据库配置
|
//如果你不需要自定义,直接配好数据库连接,F5运行项目
|
||||||
const SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer;
|
const SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer;
|
||||||
const string connectionString = "server=.;uid=sa;pwd=@jhl85661501;database=SqlSugar4XTest";
|
const string connectionString = "server=.;uid=sa;pwd=@jhl85661501;database=SqlSugar4XTest";
|
||||||
|
|
||||||
@@ -71,6 +71,11 @@ namespace SugarCodeGeneration
|
|||||||
UpdateCsproj();
|
UpdateCsproj();
|
||||||
Print("项目解决方案修改成功");
|
Print("项目解决方案修改成功");
|
||||||
|
|
||||||
|
|
||||||
|
/***添加项目引用***/
|
||||||
|
Methods.AddRef(bllProjectName2,classProjectName);
|
||||||
|
Print("引用添加成功");
|
||||||
|
|
||||||
//如何使用创建好的业务类(注意 SchoolManager 不能是静态的)
|
//如何使用创建好的业务类(注意 SchoolManager 不能是静态的)
|
||||||
//SchoolManager sm = new SchoolManager();
|
//SchoolManager sm = new SchoolManager();
|
||||||
//sm.GetList();
|
//sm.GetList();
|
||||||
|
Reference in New Issue
Block a user