From 07b74b187ecbd965c90315ec26a45406da33bf6a Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 17 Jul 2023 19:13:41 +0800 Subject: [PATCH] Add Queryable.InIF(+3) --- .../QueryableProvider/QueryableProvider.cs | 11 +++++++++ .../QueryableProvider02-05.cs | 24 +++++++++++++++++++ Src/Asp.Net/SqlSugar/Interface/IQueryable.cs | 4 ++++ 3 files changed, 39 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 4a9953b66..8c1e9cc5d 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -901,6 +901,17 @@ namespace SqlSugar if (list == null) return default(T); else return list.SingleOrDefault(); } + public ISugarQueryable InIF(bool isIn,string fieldName, params TParamter[] pkValues) + { + if (isIn) + { + return In(fieldName, pkValues); + } + else + { + return this; + } + } public ISugarQueryable InIF(bool isIn, params TParamter[] pkValues) { if (isIn) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs index 64b00ee4e..65ded1e71 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs @@ -440,6 +440,14 @@ namespace SqlSugar #endregion #region In + public new ISugarQueryable InIF(bool isIn, string fieldName, params TParamter[] pkValues) + { + if (isIn) + { + In(fieldName, pkValues); + } + return this; + } public new ISugarQueryable InIF(bool isIn, params TParamter[] pkValues) { if (isIn) @@ -1133,6 +1141,14 @@ namespace SqlSugar #endregion #region In + public new ISugarQueryable InIF(bool isIn, string fieldName, params TParamter[] pkValues) + { + if (isIn) + { + In(fieldName, pkValues); + } + return this; + } public new ISugarQueryable InIF(bool isIn, params TParamter[] pkValues) { if (isIn) @@ -1843,6 +1859,14 @@ namespace SqlSugar #endregion #region In + public new ISugarQueryable InIF(bool isIn, string fieldName, params TParamter[] pkValues) + { + if (isIn) + { + In(fieldName, pkValues); + } + return this; + } public new ISugarQueryable InIF(bool isIn, params TParamter[] pkValues) { if (isIn) diff --git a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs index cb38bb419..66b0fbe71 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs @@ -95,6 +95,7 @@ namespace SqlSugar T InSingle(object pkValue); Task InSingleAsync(object pkValue); ISugarQueryable In(params TParamter[] pkValues); + ISugarQueryable InIF(bool isIn, string fieldName, params TParamter[] pkValues); ISugarQueryable InIF(bool isIn,params TParamter[] pkValues); ISugarQueryable In(string InFieldName, params FieldType[] inValues); ISugarQueryable In(Expression> expression, params FieldType[] inValues); @@ -371,6 +372,7 @@ namespace SqlSugar ISugarQueryable In(Expression> expression, List inValues); ISugarQueryable In(Expression> expression, ISugarQueryable childQueryExpression); new ISugarQueryable InIF(bool isIn, params TParamter[] pkValues); + new ISugarQueryable InIF(bool isIn, string fieldName, params TParamter[] pkValues); #endregion #region Other @@ -506,6 +508,7 @@ namespace SqlSugar ISugarQueryable In(Expression> expression, ISugarQueryable childQueryExpression); new ISugarQueryable InIF(bool isIn, params TParamter[] pkValues); + new ISugarQueryable InIF(bool isIn, string fieldName, params TParamter[] pkValues); #endregion #region Other @@ -647,6 +650,7 @@ namespace SqlSugar ISugarQueryable In(Expression> expression, ISugarQueryable childQueryExpression); new ISugarQueryable InIF(bool isIn, params TParamter[] pkValues); + new ISugarQueryable InIF(bool isIn, string fieldName, params TParamter[] pkValues); #endregion #region Other