Files
SqlSugar/Src/Asp.NetCore2/MySqlTest/UserTestCases/UnitTest/Unitdfasdyss.cs
sunkaixuan 0d5a5110f4 Add demo
2025-07-31 13:32:45 +08:00

55 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
using System.Reflection;
using SqlSugar;
internal class Unitsdfasfasa
{
public static void Init()
{
var db = NewUnitTest.Db;
db.CurrentConnectionConfig.SlaveConnectionConfigs =
new List<SlaveConnectionConfig>() {
new()
{
HitRate=10,
ConnectionString = NewUnitTest.Db.CurrentConnectionConfig.ConnectionString,
}
};
var types = Assembly.GetExecutingAssembly().GetTypes()
.Where(type => !type.IsGenericType)
.Where(s=>s.Namespace== "WebApplication4")
.Where(type => !type.IsInterface)
.Where(type => !type.IsAbstract)
.Where(type => IntrospectionExtensions.GetTypeInfo(type).IsClass)
.Where(type => type.GetCustomAttribute<SqlSugar.SugarTable>() != null)
.ToArray();
#region
//var diffString2 = db.CodeFirst.GetDifferenceTables(types).ToDiffString();
#endregion
#region
foreach (var type in types)
{
try
{
var diffString = db.CodeFirst.GetDifferenceTables(type).ToDiffString();
db.CodeFirst.InitTables(type);
}
catch (Exception ex)
{
Console.WriteLine($"type = {type.Name} 错误: {ex}");
}
}
#endregion
}
}
}