You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
940 B
C#
28 lines
940 B
C#
using System.Data.Common;
|
|
using SqlSugar.DistributedSystem.Snowflake;
|
|
|
|
namespace NPin.Framework.SqlSugarCore;
|
|
|
|
public class SqlSugarDbContextCreationContext
|
|
{
|
|
public static readonly AsyncLocal<SqlSugarDbContextCreationContext> _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);
|
|
}
|
|
} |