Learn.Archives/Learn.Archives.Core/Common/Repository.cs

33 lines
831 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);
ISqlSugarClient d;
if (AppCommon.UserCenterType.Contains(t))
d = DbScoped.SugarScope.GetConnectionScope(1001);
else
d = DbScoped.SugarScope;
base.Context = d;
SqlSugarExpand.SetDbAop(base.Context);
}
}
}