sunkaixuna
3 years ago
4 changed files with 38 additions and 1 deletions
@ -0,0 +1,10 @@ |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace SqlSugar |
|||
{ |
|||
//public class ScopedClient : ISqlSugarClient, ITenant
|
|||
//{
|
|||
|
|||
//}
|
|||
} |
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using System.Collections.Concurrent; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace SqlSugar |
|||
{ |
|||
public class CallContextAsync<T> |
|||
{ |
|||
static ConcurrentDictionary<string, AsyncLocal<T>> state = new ConcurrentDictionary<string, AsyncLocal<T>>(); |
|||
public static void SetData(string name, T data) => |
|||
state.GetOrAdd(name, _ => new AsyncLocal<T>()).Value = data; |
|||
public static T GetData(string name) => |
|||
state.TryGetValue(name, out AsyncLocal<T> data) ? data.Value : default(T); |
|||
} |
|||
} |
Loading…
Reference in new issue