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

48 lines
1.5 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;
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
}
}
}