1
0
Fork 0
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.

37 lines
1.3 KiB
C#

using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository
{
public class Repository<T> : SimpleClient<T> where T : class, new()
{
public Repository(dynamic configId)
{
base.Context = SqlSugarHelper.Db.GetConnectionScope(configId);
//.NET自带IOC: base.Context = 你存储的Services.GetService<ISqlSugarClient>();
//Furion: base.Context=App.GetService<ISqlSugarClient>();
//Furion脚手架: base.Context=DbContext.Instance
//SqlSugar.Ioc: base.Context=DbScoped.SugarScope;
//手动去赋值: base.Context=DbHelper.GetDbInstance()
//动态添加
//if (!SqlSugarHelper.Db.IsAnyConnection("用户读出来的数据库ConfigId"))
//{
// SqlSugarHelper.Db.AddConnection(new ConnectionConfig() { 数据库读出来信息 });
//}
//base.Context = SqlSugarHelper.Db.GetConnectionScope("用户读出来的数据库ConfigId");
}
public SqlSugarScope _db()
{
return base.Context as SqlSugarScope;
}
}
}