From 9cf9ebc2e584d99ffca5170c8320c4933ac9d221 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 17 May 2024 15:54:17 +0800 Subject: [PATCH] Add OrderByPropertyNameIF --- .../QueryableProvider/QueryableProvider.cs | 8 +++++ .../QueryableProvider02-05.cs | 32 +++++++++++++++++++ .../QueryableProvider06-10.cs | 8 +++++ Src/Asp.Net/SqlSugar/Interface/IQueryable.cs | 6 ++++ 4 files changed, 54 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 88c9ba13c..0b4c65737 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -1263,6 +1263,14 @@ namespace SqlSugar this.QueryBuilder.SampleBy = sql; return this; } + public ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null) + { + if (isOrderBy) + { + return this.OrderByPropertyName(orderPropertyName,orderByType); + } + return this; + } public ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null) { if (orderPropertyName.HasValue()) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs index 16cca805c..64cd8c838 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs @@ -21,6 +21,14 @@ namespace SqlSugar this.QueryBuilder.Hints = hints; return this; } + public new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null) + { + if (isOrderBy) + { + return this.OrderByPropertyName(orderPropertyName, orderByType); + } + return this; + } public new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null) { base.OrderByPropertyName(orderPropertyName, orderByType); @@ -692,6 +700,14 @@ namespace SqlSugar this.QueryBuilder.Hints = hints; return this; } + public new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null) + { + if (isOrderBy) + { + return this.OrderByPropertyName(orderPropertyName, orderByType); + } + return this; + } public new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null) { base.OrderByPropertyName(orderPropertyName, orderByType); @@ -1469,6 +1485,14 @@ namespace SqlSugar this.QueryBuilder.Hints = hints; return this; } + public new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null) + { + if (isOrderBy) + { + return this.OrderByPropertyName(orderPropertyName, orderByType); + } + return this; + } public new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null) { base.OrderByPropertyName(orderPropertyName, orderByType); @@ -2272,6 +2296,14 @@ namespace SqlSugar base.OrderByPropertyName(orderPropertyName, orderByType); return this; } + public new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null) + { + if (isOrderBy) + { + return this.OrderByPropertyName(orderPropertyName, orderByType); + } + return this; + } public new ISugarQueryable SampleBy(int timeNumber, SampleByUnit timeType) { base.SampleBy(timeNumber, timeType); diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs index 4e7fda172..036989275 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs @@ -20,6 +20,14 @@ namespace SqlSugar this.QueryBuilder.Hints = hints; return this; } + public new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null) + { + if (isOrderBy) + { + return this.OrderByPropertyName(orderPropertyName, orderByType); + } + return this; + } public new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null) { base.OrderByPropertyName(orderPropertyName, orderByType); diff --git a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs index bcbab6111..1dbff6a53 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs @@ -115,6 +115,7 @@ namespace SqlSugar ISugarQueryable OrderBy(string orderByFields); ISugarQueryable OrderByPropertyName(string orderPropertyName,OrderByType? orderByType=null); + ISugarQueryable OrderByPropertyNameIF(bool isOrderBy,string orderPropertyName, OrderByType? orderByType = null); ISugarQueryable OrderBy(Expression> expression, OrderByType type = OrderByType.Asc); ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByIF(bool isOrderBy, string orderByFields); @@ -375,6 +376,7 @@ namespace SqlSugar #region OrderBy new ISugarQueryable OrderBy(List models); new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null); + new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null); new ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression); new ISugarQueryable OrderBy(string orderByFields); @@ -506,6 +508,7 @@ namespace SqlSugar #region OrderBy new ISugarQueryable OrderBy(List models); new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null); + new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null); new ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression); @@ -653,6 +656,7 @@ namespace SqlSugar #region OrderBy new ISugarQueryable OrderBy(List models); new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null); + new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null); new ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression); @@ -806,6 +810,7 @@ namespace SqlSugar #region OrderBy new ISugarQueryable OrderBy(List models); new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null); + new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null); new ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression); @@ -950,6 +955,7 @@ namespace SqlSugar #region OrderBy new ISugarQueryable OrderBy(List models); + new ISugarQueryable OrderByPropertyNameIF(bool isOrderBy, string orderPropertyName, OrderByType? orderByType = null); new ISugarQueryable OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null); new ISugarQueryable OrderByDescending(Expression> expression); ISugarQueryable OrderByDescending(Expression> expression);