diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index e15266bda..97afb24aa 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -357,6 +357,13 @@ namespace SqlSugar var entityName = typeof(T).Name; return _As(tableName, entityName); } + + public ISugarQueryable IF(bool condition, Action> action) + { + if(condition) + action(this); + return this; + } public ISugarQueryable AsWithAttr() { var asName=GetTableName(this.EntityInfo, this.EntityInfo.DbTableName); diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs index 64cd8c838..1e05addf1 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs @@ -16,6 +16,10 @@ namespace SqlSugar #region T2 public partial class QueryableProvider : QueryableProvider, ISugarQueryable { + public new ISugarQueryable IF(bool condition, Action> action) + { + throw new Exception("Only Queryable().IF is supported, and Queryable().IF is not supported"); + } public new ISugarQueryable Hints(string hints) { this.QueryBuilder.Hints = hints; @@ -695,6 +699,10 @@ namespace SqlSugar #region T3 public partial class QueryableProvider : QueryableProvider, ISugarQueryable { + public new ISugarQueryable IF(bool condition, Action> action) + { + throw new Exception("Only Queryable().IF is supported, and Queryable().IF is not supported"); + } public new ISugarQueryable Hints(string hints) { this.QueryBuilder.Hints = hints; @@ -1480,6 +1488,10 @@ namespace SqlSugar #region T4 public partial class QueryableProvider : QueryableProvider, ISugarQueryable { + public new ISugarQueryable IF(bool condition, Action> action) + { + throw new Exception("Only Queryable().IF is supported, and Queryable().IF is not supported"); + } public new ISugarQueryable Hints(string hints) { this.QueryBuilder.Hints = hints; @@ -2286,6 +2298,10 @@ namespace SqlSugar #region T5 public partial class QueryableProvider : QueryableProvider, ISugarQueryable { + public new ISugarQueryable IF(bool condition, Action> action) + { + throw new Exception("Only Queryable().IF is supported, and Queryable().IF is not supported");ss + } public new ISugarQueryable Hints(string hints) { this.QueryBuilder.Hints = hints; diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs index aee971089..767cfb1bf 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs @@ -15,6 +15,10 @@ namespace SqlSugar #region T6 public partial class QueryableProvider : QueryableProvider, ISugarQueryable { + public new ISugarQueryable IF(bool condition, Action> action) + { + throw new Exception("Only Queryable().IF is supported, and Queryable().IF is not supported"); + } public new ISugarQueryable Hints(string hints) { this.QueryBuilder.Hints = hints; diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs index ac17550d1..7d45895f9 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs @@ -20,6 +20,7 @@ namespace SqlSugar ISugarQueryable Hints(string hints); ISugarQueryable AS(string tableName); ISugarQueryable AS(string tableName); + ISugarQueryable IF(bool condition, Action> action); ISugarQueryable AsWithAttr(); ISugarQueryable AsType(Type tableNameType); ISugarQueryable Cast(); @@ -332,6 +333,7 @@ namespace SqlSugar } public partial interface ISugarQueryable : ISugarQueryable { + new ISugarQueryable IF(bool condition, Action> action); new ISugarQueryable Hints(string hints); new ISugarQueryable SampleBy(int timeNumber, SampleByUnit timeType); new ISugarQueryable SampleBy(int timeNumber, string timeType); @@ -462,6 +464,7 @@ namespace SqlSugar } public partial interface ISugarQueryable : ISugarQueryable { + new ISugarQueryable IF(bool condition, Action> action); new ISugarQueryable Hints(string hints); new ISugarQueryable SampleBy(int timeNumber, SampleByUnit timeType); new ISugarQueryable SampleBy(int timeNumber, string timeType); @@ -607,6 +610,7 @@ namespace SqlSugar } public partial interface ISugarQueryable : ISugarQueryable { + new ISugarQueryable IF(bool condition, Action> action); new ISugarQueryable Hints(string hints); new ISugarQueryable SampleBy(int timeNumber, SampleByUnit timeType); new ISugarQueryable SampleBy(int timeNumber, string timeType); @@ -758,6 +762,7 @@ namespace SqlSugar } public partial interface ISugarQueryable : ISugarQueryable { + new ISugarQueryable IF(bool condition, Action> action); new ISugarQueryable Hints(string hints); new ISugarQueryable SampleBy(int timeNumber, SampleByUnit timeType); new ISugarQueryable SampleBy(int timeNumber, string timeType); @@ -904,6 +909,7 @@ namespace SqlSugar } public partial interface ISugarQueryable : ISugarQueryable { + new ISugarQueryable IF(bool condition, Action> action); new ISugarQueryable Hints(string hints); ISugarQueryable SelectMergeTable(Expression> expression); ISugarQueryable LeftJoinIF(bool isLeftJoin, Expression> joinExpression);