Optimization hits&hasvalue

This commit is contained in:
sunkaixuan
2025-12-18 08:56:33 +08:00
parent 021e6f855b
commit 9ecdd37333
2 changed files with 7 additions and 2 deletions

View File

@@ -88,7 +88,8 @@ namespace SqlSugar
string oldOrderValue = this.OrderByValue;
string result = null;
sql = new StringBuilder();
sql.AppendFormat(SqlTemplate, "Count(*)", GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString);
var hints = this.Hints.HasValue() ? $" {this.Hints} Count(*)": "Count(*)";
sql.AppendFormat(SqlTemplate,hints, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString);
if (IsCount)
{
if (sql.ToString().Contains("-- No table"))

View File

@@ -58,7 +58,11 @@ namespace SqlSugar
public static bool HasValue(this object thisValue)
{
if (thisValue == null || thisValue == DBNull.Value) return false;
return thisValue.ToString() != "";
if (thisValue is string s)
{
return !string.IsNullOrEmpty(s);
}
return thisValue != null;
}
public static bool HasValue(this IEnumerable<object> thisValue)