You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Reflection;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
using DS.WMS.Core.System.Entity;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using SqlSugar.IOC;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Ds.WMS.Test;
|
|
|
|
|
|
|
|
|
|
public class SaasTest
|
|
|
|
|
{
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
private readonly SqlSugarScope db;
|
|
|
|
|
private readonly ISaasDbService saasService;
|
|
|
|
|
public SaasTest(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SaasTest1()
|
|
|
|
|
{
|
|
|
|
|
Type[] types= Assembly
|
|
|
|
|
.LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
|
|
|
|
|
.GetTypes().Where(it=>it.FullName.Contains("DS.WMS.Core.Code.Entity.")||it.FullName.Contains("DS.WMS.Core.Info.Entity.")||it.FullName.Contains("DS.WMS.Core.Sea.Entity."))//命名空间过滤,当然你也可以写其他条件过滤
|
|
|
|
|
.ToArray();
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
|
|
|
|
|
// var temp = tenantDb.CodeFirst.GetDifferenceTables(types);
|
|
|
|
|
// var diffString= tenantDb.CodeFirst.GetDifferenceTables(types).ToDiffString();
|
|
|
|
|
StaticConfig.CodeFirst_MySqlCollate="utf8mb4_0900_ai_ci";//较高版本支持
|
|
|
|
|
tenantDb.CodeFirst.InitTables(types);
|
|
|
|
|
// //初始化数库
|
|
|
|
|
// tenantDb.DbMaintenance.CreateDatabase();
|
|
|
|
|
//
|
|
|
|
|
// tenantDb.CodeFirst.InitTables(typeof(CodeCountry));
|
|
|
|
|
Assert.True(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|