mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:43:26 +08:00
接口【修复】:修复商品列表多种查询排序问题。
This commit is contained in:
@@ -1632,7 +1632,7 @@ namespace CoreCms.Net.Repository
|
|||||||
|
|
||||||
sqlCom.Where(predicate);
|
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
|
//为了防止sql注入,所以需要遍历一遍,改成参数化执行sql
|
||||||
if (!string.IsNullOrEmpty(orderByExpression))
|
if (!string.IsNullOrEmpty(orderByExpression))
|
||||||
@@ -1642,29 +1642,29 @@ namespace CoreCms.Net.Repository
|
|||||||
{
|
{
|
||||||
if (orderString.Contains("price asc"))
|
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"))
|
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"))
|
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"))
|
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"))
|
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"))
|
else if (orderString.Contains("sort desc"))
|
||||||
{
|
{
|
||||||
sqlCom.OrderBy(it => it.sort, OrderByType.Desc);
|
sqlCom = sqlCom.OrderBy(it => SqlFunc.Desc(it.sort));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user