31 lines
832 B
C#
31 lines
832 B
C#
using Learn.Archives.Core.Common.Expand;
|
|
using SqlSugar;
|
|
using SqlSugar.IOC;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UserCenter.Model;
|
|
|
|
namespace Learn.Archives.Core.Common
|
|
{
|
|
public class Repository<T> : SimpleClient<T> where T : class, new()
|
|
{
|
|
public Repository()
|
|
{
|
|
SwitchConnection();
|
|
}
|
|
public void SwitchConnection()
|
|
{
|
|
var t = typeof(T);
|
|
if (AppCommon.DbMatserType.Contains(t))
|
|
base.Context = DbScoped.SugarScope;
|
|
else if (AppCommon.UserCenterType.Contains(t))
|
|
base.Context = DbScoped.SugarScope.GetConnectionScope(1001);
|
|
SqlSugarExpand.SetDbAop(base.Context);
|
|
}
|
|
}
|
|
}
|