修改代码生成动态查询库表字符串

This commit is contained in:
不做码农 2022-05-31 11:45:48 +08:00
parent 1ca160f3c1
commit 3b8ec3cc95

View File

@ -1,4 +1,5 @@
using Infrastructure; using Infrastructure;
using Infrastructure.Extensions;
using SqlSugar; using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -28,8 +29,16 @@ namespace ZR.CodeGenerator
if (!string.IsNullOrEmpty(dbName)) if (!string.IsNullOrEmpty(dbName))
{ {
string replaceStr = GetValue(connStr, "database=", ";"); string replaceStr = GetValue(connStr, "Database=", ";");
connStr = connStr.Replace(replaceStr, dbName); string replaceStr2 = GetValue(connStr, "Initial Catalog=", ";");
if (replaceStr.IsNotEmpty())
{
connStr = connStr.Replace(replaceStr, dbName, StringComparison.OrdinalIgnoreCase);
}
if (replaceStr2.IsNotEmpty())
{
connStr = connStr.Replace(replaceStr2, dbName, StringComparison.OrdinalIgnoreCase);
}
} }
var db = new SqlSugarClient(new List<ConnectionConfig>() var db = new SqlSugarClient(new List<ConnectionConfig>()
{ {