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

29 lines
730 B
C#

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.Sugar;
else if (AppCommon.UserCenterType.Contains(t))
base.Context = DbScoped.Sugar.GetConnectionScope(1001);
}
}
}