/// <summary> /// 增加排序条件(可以改进查找匹配算法?) /// </summary> /// <param name="sqlExpression"></param> public void Add(PageSort pagesort) { #region for (int i = 0; i < this.Count; i++) { if (pagesort._FieldName == ((PageSort)List[i])._FieldName) { ExtConsole.WriteWithColor("不能重复添加排序字段!"); return; } } List.Add(pagesort); #endregion }
/// <summary> /// /// </summary> /// <returns></returns> public override String ToString() { #region string orderby = ""; string format = ""; if (this != null) { for (int i = 0; i < this.Count; i++) { PageSort pagesort = this[i]; format = (i == 0) ? "{0} {1}" : ",{0} {1}"; orderby += string.Format(format, pagesort._FieldName, getAscOrDesc(pagesort._OrderBy)); } if (this.Count > 0) { orderby = string.Format("order by {0}", orderby); } } return(orderby); #endregion }