feat: 动态表达式 SqlFunc 支持,增加删除自定义过滤器缓存
This commit is contained in:
parent
cf3e6d8a25
commit
ef9d326131
@ -32,6 +32,17 @@ public static class SqlSugarFilter
|
||||
_cache.Remove($"db:{dbConfigId}:orgList:{userId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除自定义过滤器缓存
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="dbConfigId"></param>
|
||||
public static void DeleteCustomCache(long userId, string dbConfigId)
|
||||
{
|
||||
// 删除自定义缓存——过滤器
|
||||
_cache.Remove($"db:{dbConfigId}:custom:{userId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置用户机构集合过滤器
|
||||
/// </summary>
|
||||
|
||||
@ -30,6 +30,12 @@ public static class SqlSugarSetup
|
||||
{
|
||||
return YitIdHelper.NextId();
|
||||
};
|
||||
// 动态表达式 SqlFunc 支持,https://www.donet5.com/Home/Doc?typeId=2569
|
||||
StaticConfig.DynamicExpressionParserType = typeof(DynamicExpressionParser);
|
||||
StaticConfig.DynamicExpressionParsingConfig = new ParsingConfig
|
||||
{
|
||||
CustomTypeProvider = new SqlSugarTypeProvider()
|
||||
};
|
||||
|
||||
var dbOptions = App.GetConfig<DbConnectionOptions>("DbConnection", true);
|
||||
dbOptions.ConnectionConfigs.ForEach(SetDbConfig);
|
||||
|
||||
20
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarTypeProvider.cs
Normal file
20
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarTypeProvider.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Linq.Dynamic.Core.CustomTypeProviders;
|
||||
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 扩展支持 SqlFunc,不支持 Subqueryable
|
||||
/// </summary>
|
||||
public class SqlSugarTypeProvider : DefaultDynamicLinqCustomTypeProvider
|
||||
{
|
||||
public SqlSugarTypeProvider( bool cacheCustomTypes = true) : base(ParsingConfig.Default, cacheCustomTypes)
|
||||
{
|
||||
}
|
||||
|
||||
public override HashSet<Type> GetCustomTypes()
|
||||
{
|
||||
var customTypes = base.GetCustomTypes();
|
||||
customTypes.Add(typeof(SqlFunc));
|
||||
return customTypes;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user