生成多字段排序分页的SQL的通用类

2019-05-12 08:49:26刘景俊

            if (orders.Count > 0) 
            { 
                string[] str = orders.AllKeys; 
                foreach (string s in str) 
                { 
                    string direction="asc";//默认一个方向 
                    if (orders[s].ToString() == "asc") 
                        direction = "desc"; 
                    //去掉前缀的字段名称 
                    string s2 = ""; 
                    int index = s.IndexOf(".") + 1; 
                    s2 = s.Substring(index); 
                    orderList =orderList + s +" "+ orders[s] +","; 
                    orderList2 = orderList2 + s2 + " " + direction + ","; 
                    orderList3 = orderList3 + s2 + " " + orders[s] + ","; 
                } 
                //去掉最后的,号 
                orderList = orderList.Substring(0,orderList.Length-1); 
                orderList2 = orderList2.Substring(0, orderList2.Length - 1);