// WingsEmu // // Developed by NosWings Team using System.ComponentModel.DataAnnotations.Schema; using System.Reflection; using Microsoft.EntityFrameworkCore; namespace PhoenixLib.DAL.EFCore.PGSQL.Extensions { public static class DatabaseClearExtensions { public static void ResetTable(this DbContext dbContext, DbSet dbSet) where T : class { dbSet.DeleteFromQuery(); dbContext.Database.ExecuteSqlRaw(CleanTable()); } private static string CleanTable() => @$"ALTER SEQUENCE ""{((TableAttribute)typeof(T).GetCustomAttribute(typeof(TableAttribute))).Schema}"".""{((TableAttribute)typeof(T).GetCustomAttribute(typeof(TableAttribute))).Name}_Id_seq"" RESTART;"; } }