diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs index 3151cff8d..d083762f1 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/FilterProvider/FilterProvider.cs @@ -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 { @@ -9,6 +12,7 @@ namespace SqlSugar { internal SqlSugarProvider Context { get; set; } private List _Filters { get; set; } + private List _BackUpFilters { get; set; } public IFilter Add(SqlFilterItem filter) { @@ -46,5 +50,51 @@ namespace SqlSugar { _Filters = new List(); } + public void ClearAndBackup() + { + _BackUpFilters = _Filters; + _Filters = new List(); + } + + public void Restore() + { + _Filters = _BackUpFilters; + if (_Filters == null) + { + _Filters = new List(); + } + } + + public void AddTableFilter(Expression> expression, FilterJoinPosition filterJoinType = FilterJoinPosition.On) where T : class,new() + { + var isOn = filterJoinType == FilterJoinPosition.On; + var tableFilter = new TableFilterItem(expression, isOn); + this.Add(tableFilter); + } + public void AddTableFilterIF(bool isAppendFilter,Expression> 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; + this.Add(new TableFilterItem(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 + } } } diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 73bc17fda..44e4dbed8 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -539,6 +539,11 @@ namespace SqlSugar FieldValue = value.ObjToStringNew(), CSharpTypeName = column.PropertyInfo.PropertyType.Name }); + if(value is Enum&&this.Context.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString!=true) + { + data.Value.FieldValue = Convert.ToInt64(value).ObjToString(); + data.Value.CSharpTypeName = "int"; + } //if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL) //{ // data.Value.FieldValueConvertFunc = it => diff --git a/Src/Asp.NetCore2/SqlSugar/IntegrationServices/SplitTableService.cs b/Src/Asp.NetCore2/SqlSugar/IntegrationServices/SplitTableService.cs index d2fb6c00c..0412abe6f 100644 --- a/Src/Asp.NetCore2/SqlSugar/IntegrationServices/SplitTableService.cs +++ b/Src/Asp.NetCore2/SqlSugar/IntegrationServices/SplitTableService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -223,7 +223,7 @@ namespace SqlSugar case SplitType.Year: return Convert.ToDateTime(time.ToString("yyyy-01-01")); default: - throw new Exception($"SplitType paramter error "); + throw new Exception($"SplitType parameter error "); } } private DateTime GetMondayDate()