优化数据过滤

This commit is contained in:
不做码农
2022-04-09 19:11:16 +08:00
parent ed483d8b56
commit 0833b70dd9
10 changed files with 53 additions and 53 deletions

View File

@@ -18,18 +18,24 @@ namespace ZR.Repository
public class BaseRepository<T> : SimpleClient<T> where T : class, new()
{
public ITenant itenant = null;//多租户事务
public BaseRepository(ISqlSugarClient client = null) : base(client)
public BaseRepository(ISqlSugarClient context = null) : base(context)
{
//通过特性拿到ConfigId
var configId = typeof(T).GetCustomAttribute<TenantAttribute>()?.configId;
if (configId != null)
//var configId = typeof(T).GetCustomAttribute<TenantAttribute>()?.configId;
//if (configId != null)
//{
// itenant = DbScoped.SugarScope;//设置租户接口
// Context = DbScoped.SugarScope.GetConnection(configId);
//}
//else
//{
// Context = context ?? DbScoped.SugarScope.GetConnection(1);//根据类传入的ConfigId自动选择
//}
Context = DbScoped.SugarScope.GetConnectionWithAttr<T>();
itenant = DbScoped.SugarScope;//设置租户接口
if (Context == null)
{
Context = DbScoped.SugarScope.GetConnection(configId);
itenant = DbScoped.SugarScope;//设置租户接口
}
else
{
Context = client ?? DbScoped.SugarScope.GetConnection(1);//根据类传入的ConfigId自动选择
Context = context ?? DbScoped.SugarScope.GetConnection(1);//根据类传入的ConfigId自动选择
}
}

View File

@@ -14,7 +14,7 @@
<PackageReference Include="MySql.Data" Version="8.0.25" />
<PackageReference Include="NETCore.Encrypt" Version="2.1.0" />
<PackageReference Include="SqlSugar.IOC" Version="1.8.0" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.6" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.6.6" />
</ItemGroup>
<ItemGroup>