SqlSugar/Src/Asp.NetCore2/KdbndpTest/OracleDemo/UnitTest/UnitSplitTask.cs

49 lines
1.2 KiB
C#
Raw Normal View History

2024-07-10 21:15:51 +08:00
using OrmTest;
using SqlSugar;
2023-10-16 12:40:08 +08:00
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
2024-07-10 21:15:51 +08:00
namespace KdbndpTest.OracleDemo.UnitTest
2023-10-16 12:40:08 +08:00
{
internal class UnitSplitTask
{
2024-07-10 21:15:51 +08:00
public static void Init()
2023-10-16 12:40:08 +08:00
{
2024-07-10 21:15:51 +08:00
var client = NewUnitTest.Db;
2023-10-16 12:40:08 +08:00
Console.WriteLine("Hello, World!");
List<Task> tasks = new List<Task>()
{
CreateTask(client.CopyNew()),
CreateTask(client.CopyNew()),
CreateTask(client.CopyNew())
};
2024-07-10 21:15:51 +08:00
Task.WhenAll(tasks).GetAwaiter().GetResult();
2023-10-16 12:40:08 +08:00
client.Deleteable(new SpitDemoModel()).SplitTable().ExecuteCommand();
}
private static Task CreateTask(ISqlSugarClient client)
{
2024-07-10 21:15:51 +08:00
return Task.Run(() =>
{
2023-10-16 12:40:08 +08:00
client.Insertable(new SpitDemoModel()).SplitTable().ExecuteCommand();
});
}
}
[SplitTable(SplitType.Day)]
[SugarTable("SpitDemo_{year}{month}{day}")]
public class SpitDemoModel
{
[SugarColumn(IsPrimaryKey = true)]
public Guid Id { get; set; } = Guid.NewGuid();
[SplitField]
public DateTime CreateTime { get; set; } = DateTime.Now.AddDays(1);
}
}
2024-07-10 21:15:51 +08:00