增加多租户的配置

This commit is contained in:
不做码农
2021-10-29 13:23:22 +08:00
parent 60c25735b0
commit 39fc3918fa
6 changed files with 28 additions and 34 deletions

View File

@@ -1,13 +1,9 @@
using Infrastructure;
using Infrastructure.Model;
using Infrastructure.Model;
using SqlSugar;
using SqlSugar.IOC;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using ZR.Model;
namespace ZR.Repository
@@ -19,34 +15,11 @@ namespace ZR.Repository
public class BaseRepository<T> : IBaseRepository<T> where T : class, new()
{
public ISqlSugarClient Context;
//private ISqlSugarClient _db
//{
// get
// {
// if (typeof(T).GetTypeInfo().GetCustomAttributes(typeof(SugarTable), true).FirstOrDefault((x => x.GetType() == typeof(SugarTable))) is SugarTable sugarTable && !string.IsNullOrEmpty(sugarTable.TableDescription))
// {
// Context.ChangeDatabase(sugarTable.TableDescription.ToLower());
// }
// else
// {
// Context.ChangeDatabase(0);
// }
// return Context;
// }
//}
public BaseRepository(ISqlSugarClient dbContext = null, string configId = "0") //: base(dbContext)
public BaseRepository(string configId = "0") //: base(dbContext)
{
if (dbContext == null)
{
Context = DbScoped.SugarScope.GetConnection(configId);//根据类传入的ConfigId自动选择
//_dbbase = Context;
}
Context = DbScoped.SugarScope.GetConnection(configId);//根据类传入的ConfigId自动选择
}
//public ISqlSugarClient Db
//{
// get { return _db; }
//}
#region add
/// <summary>
/// 插入指定列使用