mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-06 05:37:58 +08:00
Optimize filter
This commit is contained in:
parent
bf469c3256
commit
8e85105724
@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using static SqlSugar.QueryFilterProvider;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
@ -46,5 +49,37 @@ namespace SqlSugar
|
||||
{
|
||||
_Filters = new List<SqlFilterItem>();
|
||||
}
|
||||
|
||||
public void AddTableFilter<T>(Expression<Func<T,bool>> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class,new()
|
||||
{
|
||||
var isOn = filterJoinType == FilterJoinPosition.On;
|
||||
var tableFilter = new TableFilterItem<T>(expression, isOn);
|
||||
_Filters.Add(tableFilter);
|
||||
}
|
||||
public void AddTableFilterIF<T>(bool isAppendFilter,Expression<Func<T, bool>> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class, new()
|
||||
{
|
||||
if (isAppendFilter)
|
||||
{
|
||||
AddTableFilter(expression, filterJoinType);
|
||||
}
|
||||
}
|
||||
public void AddTableFilter(Type type,Expression expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On)
|
||||
{
|
||||
var isOn = filterJoinType == FilterJoinPosition.On;
|
||||
_Filters.Add(new TableFilterItem<object>(type, expression, isOn));
|
||||
}
|
||||
|
||||
public void AddTableFilterIF(bool isAppendFilter, Type type, Expression expression, FilterJoinPosition posType = FilterJoinPosition.On)
|
||||
{
|
||||
if (isAppendFilter)
|
||||
{
|
||||
AddTableFilter(type, expression, posType);
|
||||
}
|
||||
}
|
||||
public enum FilterJoinPosition
|
||||
{
|
||||
On=0,
|
||||
Where=1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user