using System.Data.Common; using SqlSugar.DistributedSystem.Snowflake; namespace NPin.Framework.SqlSugarCore; public class SqlSugarDbContextCreationContext { public static readonly AsyncLocal _current = new(); public static SqlSugarDbContextCreationContext Current => _current.Value; public string ConnectionStringName { get; } public string ConnectionString { get; } // public DbConnection ExistsConnection { get; internal set; } public SqlSugarDbContextCreationContext(string connectionStringName, string connectionString) { ConnectionStringName = connectionStringName; ConnectionString = connectionString; } public static IDisposable Use(SqlSugarDbContextCreationContext context) { var previousValue = Current; _current.Value = context; return new DisposableAction(() => _current.Value = previousValue); } }