Browse Source

Synchronization code

pull/31/head
sunkaixuan 2 years ago
parent
commit
91354ddc95
  1. 30
      Src/Asp.Net/SqlSugar/Abstract/FilterProvider/FilterProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs
  3. 12
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  4. 20
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs
  5. 25
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs
  6. 10
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs
  7. 29
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs
  8. 2
      Src/Asp.Net/SqlSugar/Entities/SqlFilter.cs
  9. 13
      Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

30
Src/Asp.Net/SqlSugar/Abstract/FilterProvider/FilterProvider.cs

@ -50,12 +50,42 @@ namespace SqlSugar
{
_Filters = new List<SqlFilterItem>();
}
public void Clear<T>()
{
_Filters = _Filters.Where(it => !(it is TableFilterItem<T>)).ToList();
}
public void Clear<T,T2>()
{
_Filters = _Filters.Where(it => !(it is TableFilterItem<T>) && !(it is TableFilterItem<T2>)).ToList();
}
public void Clear<T, T2,T3>()
{
_Filters = _Filters.Where(it => !(it is TableFilterItem<T>) && !(it is TableFilterItem<T2>) && !(it is TableFilterItem<T3>)).ToList();
}
public void ClearAndBackup()
{
_BackUpFilters = _Filters;
_Filters = new List<SqlFilterItem>();
}
public void ClearAndBackup<T>()
{
_BackUpFilters = _Filters;
_Filters = _BackUpFilters.Where(it=>!(it is TableFilterItem<T>)).ToList();
}
public void ClearAndBackup<T,T2>()
{
_BackUpFilters = _Filters;
_Filters = _BackUpFilters.Where(it => !(it is TableFilterItem<T>)&&!(it is TableFilterItem<T2>)).ToList();
}
public void ClearAndBackup<T, T2 , T3>()
{
_BackUpFilters = _Filters;
_Filters = _BackUpFilters.Where(it => !(it is TableFilterItem<T>) && !(it is TableFilterItem<T2>) && !(it is TableFilterItem<T3>)).ToList();
}
public void Restore()
{
_Filters = _BackUpFilters;

1
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs

@ -1556,6 +1556,7 @@ namespace SqlSugar
asyncQueryableBuilder.SubToListParameters= this.Context.Utilities.TranslateCopy(this.QueryBuilder.SubToListParameters);
asyncQueryableBuilder.AppendColumns = this.Context.Utilities.TranslateCopy(this.QueryBuilder.AppendColumns);
asyncQueryableBuilder.AppendValues = this.Context.Utilities.TranslateCopy(this.QueryBuilder.AppendValues);
asyncQueryableBuilder.RemoveFilters = this.QueryBuilder.RemoveFilters?.ToArray();
}
protected int SetCacheTime(int cacheDurationInSeconds)
{

12
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -260,6 +260,18 @@ namespace SqlSugar
_Filter(FilterName, isDisabledGobalFilter);
return this;
}
public ISugarQueryable<T> ClearFilter()
{
this.Filter(null, true);
return this;
}
public ISugarQueryable<T> ClearFilter(params Type[] types)
{
this.QueryBuilder.RemoveFilters = types;
this.Filter(null, true);
return this;
}
public ISugarQueryable<T> Filter(Type type)
{
this.Context.InitMappingInfo(type);

20
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs

@ -453,6 +453,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T,T2> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -1080,6 +1085,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -1717,6 +1727,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3,T4> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -2288,6 +2303,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4,T5> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);

25
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs

@ -554,6 +554,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5,T6> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -1134,6 +1139,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -1706,6 +1716,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6,T7,T8> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -2289,6 +2304,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -2891,6 +2911,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);

10
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs

@ -582,6 +582,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);
@ -1158,6 +1163,11 @@ namespace SqlSugar
_As(tableName, entityName);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> ClearFilter()
{
this.Filter(null, true);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Filter(string FilterName, bool isDisabledGobalFilter = false)
{
_Filter(FilterName, isDisabledGobalFilter);

29
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

@ -34,6 +34,7 @@ namespace SqlSugar
#endregion
#region Splicing basic
public Type[] RemoveFilters { get; set; }
public Dictionary<string, object> SubToListParameters { get; set; }
internal List<QueryableAppendColumn> AppendColumns { get; set; }
internal List<List<QueryableAppendColumn>> AppendValues { get; set; }
@ -297,23 +298,36 @@ namespace SqlSugar
if (this.Context != null)
{
var db = Context;
BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic;
BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic| BindingFlags.Public;
var index = 0;
if (db.QueryFilter.GeFilterList != null)
{
foreach (var item in db.QueryFilter.GeFilterList)
{
if (this.RemoveFilters != null && this.RemoveFilters.Length > 0)
{
if (this.RemoveFilters.Contains(item.type))
{
continue;
}
}
PropertyInfo field = item.GetType().GetProperty("exp", flag);
if (field != null)
{
Type ChildType = item.GetType().GetProperty("type", flag).GetValue(item, null) as Type;
if (ChildType == type)
Type ChildType = item.type;
var isInterface = ChildType.IsInterface && type.GetInterfaces().Any(it => it == ChildType);
if (ChildType == type|| isInterface)
{
var entityInfo = db.EntityMaintenance.GetEntityInfo(ChildType);
var exp = field.GetValue(item, null) as Expression;
var whereStr = index==0 ? " " : " AND ";
index++;
result += (whereStr + GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetString());
if (isInterface)
{
result = ReplaceFilterColumnName(result,type);
}
}
}
}
@ -361,7 +375,10 @@ namespace SqlSugar
if (!IsDisabledGobalFilter && this.Context.QueryFilter.GeFilterList.HasValue())
{
var gobalFilterList = this.Context.QueryFilter.GeFilterList.Where(it => it.FilterName.IsNullOrEmpty()).ToList();
if (this.RemoveFilters != null && this.RemoveFilters.Length > 0)
{
gobalFilterList = gobalFilterList.Where(it => !this.RemoveFilters.Contains(it.type)).ToList();
}
foreach (var item in gobalFilterList)
{
if (item.GetType().Name.StartsWith("TableFilterItem"))
@ -384,10 +401,10 @@ namespace SqlSugar
private void AppendTableFilter(SqlFilterItem item)
{
BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic;
BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic |BindingFlags.Public;
Type type = item.GetType();
PropertyInfo field = type.GetProperty("exp", flag);
Type ChildType = type.GetProperty("type", flag).GetValue(item, null) as Type;
Type ChildType = item.type;
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(ChildType);
var exp = field.GetValue(item, null) as Expression;
var isMain = ChildType == this.EntityType||(ChildType.IsInterface&& this.EntityType.GetInterfaces().Any(it => it == ChildType));

2
Src/Asp.Net/SqlSugar/Entities/SqlFilter.cs

@ -17,6 +17,7 @@ namespace SqlSugar
/// Is it a multiple table query?
/// </summary>
public bool IsJoinQuery { get; set; }
internal Type type { get; set; }
}
public class TableFilterItem<T>: SqlFilterItem
@ -26,7 +27,6 @@ namespace SqlSugar
}
private Expression exp { get; set; }
private Type type { get; set; }
public TableFilterItem(Expression<Func<T,bool>> expression,bool isJoinOn=false)
{
exp = expression;

13
Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

@ -33,6 +33,8 @@ namespace SqlSugar
ISugarQueryable<T, T2> InnerJoin<T2>(Expression<Func<T, T2, bool>> joinExpression);
ISugarQueryable<T, T2> RightJoin<T2>(Expression<Func<T, T2, bool>> joinExpression);
ISugarQueryable<T> Filter(string FilterName, bool isDisabledGobalFilter = false);
ISugarQueryable<T> ClearFilter(params Type[] types);
ISugarQueryable<T> ClearFilter();
ISugarQueryable<T> Filter(Type type);
ISugarQueryable<T> Mapper(Action<T> mapperAction);
ISugarQueryable<T> Mapper<AType, BType, MappingType>(Expression<Func<MappingType, ManyToMany>> expression);
@ -315,6 +317,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2> Clone();
new ISugarQueryable<T, T2> AS<AsT>(string tableName);
new ISugarQueryable<T, T2> AS(string tableName);
new ISugarQueryable<T,T2> ClearFilter();
new ISugarQueryable<T, T2> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2> AddParameters(object parameters);
new ISugarQueryable<T, T2> AddParameters(SugarParameter[] parameters);
@ -436,6 +439,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3> Clone();
new ISugarQueryable<T, T2, T3> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3> AS(string tableName);
new ISugarQueryable<T, T2,T3> ClearFilter();
new ISugarQueryable<T, T2, T3> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3> AddParameters(SugarParameter[] parameters);
@ -563,6 +567,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4> Clone();
new ISugarQueryable<T, T2, T3, T4> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4> AS(string tableName);
new ISugarQueryable<T, T2, T3,T4> ClearFilter();
new ISugarQueryable<T, T2, T3, T4> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4> AddParameters(SugarParameter[] parameters);
@ -682,6 +687,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5> Clone();
new ISugarQueryable<T, T2, T3, T4, T5> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4,T5> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5> AddParameters(SugarParameter[] parameters);
@ -810,6 +816,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5, T6> Clone();
new ISugarQueryable<T, T2, T3, T4, T5, T6> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5,T6> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5, T6> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5, T6> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5, T6> AddParameters(SugarParameter[] parameters);
@ -925,6 +932,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Clone();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AddParameters(SugarParameter[] parameters);
@ -1046,6 +1054,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Clone();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AddParameters(SugarParameter[] parameters);
@ -1161,6 +1170,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Clone();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AddParameters(SugarParameter[] parameters);
@ -1280,6 +1290,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Clone();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9,T10> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AddParameters(SugarParameter[] parameters);
@ -1403,6 +1414,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Clone();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AddParameters(SugarParameter[] parameters);
@ -1525,6 +1537,7 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Clone();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AS<AsT>(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AS(string tableName);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> ClearFilter();
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Filter(string FilterName, bool isDisabledGobalFilter = false);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AddParameters(object parameters);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AddParameters(SugarParameter[] parameters);

Loading…
Cancel
Save