SWCMS.Utils/SqlHelp.cs
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Web;
using System.IO;
using System.Net;
namespace SWCMS.Utils
{
/// <summary>
/// sql语句生成代码
/// </summary>
public class SqlHelp
{
#region sql语句生成代码
/// <summary>
/// 分页sql语句,支持多个字段
/// </summary>
/// <param name="SelectFields">输出字段,以逗号隔开(记住:一定要将排序所用到的字段一并输出)</param>
/// <param name="TblName">表名</param>
/// <param name="PageSize">每页记录数</param>
/// <param name="PageIndex">页码</param>
/// <param name="Order">排序方式</param>
/// <param name="whereStr">搜索条件</param>
/// <returns></returns>
public static string GetSql1(string SelectFields, string TblName, int TotalCount, int PageSize, int PageIndex, NameValueCollection Order, string whereStr)
{
//排序字段
string orderList = "";//用户期望的排序
string orderList2 = "";//对用户期望的排序的反排序
string orderList3 = "";//用户期望的排序,去掉了前缀.复合查询里的外层的排序不能是类似这样的table1.id,要去掉table1.。
if (Order.Count > 0)
{
string[] str = Order.AllKeys;
foreach (string s in str)
{
string direction = "asc";//默认一个方向
if (Order[s].ToString() == "asc")
direction = "desc";
//去掉前缀的字段名称
string s2 = "";
int index = s.IndexOf(".") + 1;
s2 = s.Substring(index);
orderList = orderList + s + " " + Order[s] + ",";
orderList2 = orderList2 + s2 + " " + direction + ",";
orderList3 = orderList3 + s2 + " " + Order[s] + ",";
}
//去掉最后的,号
orderList = orderList.Substring(0, orderList.Length - 1);
orderList2 = orderList2.Substring(0, orderList2.Length - 1);
orderList3 = orderList3.Substring(0, orderList3.Length - 1);
}
//形成SQL
string strTemp;
//判断是不是最后一页
if ((TotalCount > 0) && (TotalCount % PageSize > 0) && (PageIndex > (TotalCount / PageSize)))
{
后面还有 133 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
