diff --git a/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs b/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs index 53e095d4..972f2256 100644 --- a/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs +++ b/CoreCms.Net.Repository/Good/CoreCmsGoodsRepository.cs @@ -1632,7 +1632,7 @@ namespace CoreCms.Net.Repository sqlCom.Where(predicate); - sqlCom.OrderBy(it => it.isRecommend, OrderByType.Desc).OrderBy(it => it.isHot, OrderByType.Desc); + sqlCom = sqlCom.OrderBy(it => it.isRecommend, OrderByType.Desc).OrderBy(it => it.isHot, OrderByType.Desc); //为了防止sql注入,所以需要遍历一遍,改成参数化执行sql if (!string.IsNullOrEmpty(orderByExpression)) @@ -1642,29 +1642,29 @@ namespace CoreCms.Net.Repository { if (orderString.Contains("price asc")) { - sqlCom.OrderBy(it => it.price, OrderByType.Asc); + sqlCom = sqlCom.OrderBy(it => SqlFunc.Asc(it.price)); } else if (orderString.Contains("price desc")) { - sqlCom.OrderBy(it => it.price, OrderByType.Desc); + sqlCom = sqlCom.OrderBy(it => SqlFunc.Desc(it.price)); } if (orderString.Contains("buyCount asc")) { - sqlCom.OrderBy(it => it.buyCount, OrderByType.Asc); + sqlCom = sqlCom.OrderBy(it => SqlFunc.Asc(it.buyCount)); } else if (orderString.Contains("buyCount desc")) { - sqlCom.OrderBy(it => it.buyCount, OrderByType.Desc); + sqlCom = sqlCom.OrderBy(it => SqlFunc.Desc(it.buyCount)); } if (orderString.Contains("sort asc")) { - sqlCom.OrderBy(it => it.sort, OrderByType.Asc); + sqlCom = sqlCom.OrderBy(it => SqlFunc.Asc(it.sort)); } else if (orderString.Contains("sort desc")) { - sqlCom.OrderBy(it => it.sort, OrderByType.Desc); + sqlCom = sqlCom.OrderBy(it => SqlFunc.Desc(it.sort)); } } }