示例#1
0
 /// <summary>
 /// 得到DataTable数据集合
 /// </summary>
 /// <param name="where"></param>
 /// <param name="orderby"></param>
 /// <param name="fields"></param>
 /// <returns></returns>
 public virtual DataTable Get_Entity_byWhere_ToTable(WhereClip where, OrderByClip orderby, params Field[] fields)
 {
     return(db.From <T>()
            .Where(where)
            .Select(fields)
            .OrderBy(orderby)
            .ToTable());
 }
示例#2
0
 /// <summary>
 /// 判断OrderByClip是否为null或空
 /// </summary>
 /// <param name="where"></param>
 /// <returns></returns>
 public static bool IsNullOrEmpty(OrderByClip order)
 {
     if ((object)order == null || string.IsNullOrEmpty(order.ToString()))
     {
         return(true);
     }
     return(false);
 }
示例#3
0
 /// <summary>
 /// 分页返回Datatable
 /// </summary>
 /// <param name="currentPageindex"></param>
 /// <param name="pageSize"></param>
 /// <param name="where"></param>
 /// <param name="orderby"></param>
 /// <param name="fields"></param>
 /// <returns></returns>
 public virtual DataTable Get_Entity_byPage_ToTable(int currentPageindex, int pageSize,
                                                    WhereClip where, OrderByClip orderby, params Field[] fields)
 {
     return(db.From <T>()
            .Where(where)
            .Select(fields)
            .OrderBy(orderby)
            .GetPage(pageSize)
            .ToTable(currentPageindex));
 }
示例#4
0
 /// <summary>
 /// 得到top的几条数据
 /// </summary>
 /// <param name="top"></param>
 /// <param name="where"></param>
 /// <param name="orderby"></param>
 /// <returns></returns>
 public virtual List <T> Get_Entitys_ByTop(int top, WhereClip where, OrderByClip orderby, params Field[] fields)
 {
     if (top == 0)
     {
         throw new Exception("top值不能为0");
     }
     return(db.From <T>()
            .Where(where)
            .Select(fields)
            .GetTop(top)
            .OrderBy(orderby)
            .ToList());
 }
示例#5
0
        /// <summary>
        /// 进行Union操作
        /// </summary>
        /// <param name="query"></param>
        /// <param name="isUnionAll"></param>
        /// <returns></returns>
        private QuerySection <T> Union(QuerySection <T> query, bool isUnionAll)
        {
            QuerySection <T> q = CreateQuery <T>();

            q.QueryString  = this.QueryString;
            q.CountString  = this.CountString;
            q.QueryString += " union " + (isUnionAll ? "all " : "") + query.QueryString;
            q.CountString += " union " + (isUnionAll ? "all " : "") + query.CountString;
            q.unionQuery   = true;

            //将排序进行合并
            OrderByClip order = this.orderBy && query.orderBy;

            q.Parameters = query.Parameters;

            return(q.OrderBy(order));
        }
示例#6
0
        /// <summary>
        /// 添加一个排序
        /// </summary>
        /// <param name="order"></param>
        public QueryCreator AddOrder(OrderByClip order)
        {
            if (DataUtils.IsNullOrEmpty(order))
            {
                return(this);
            }

            if (orderList.Exists(o =>
            {
                return(string.Compare(order.ToString(), o.ToString()) == 0);
            }))
            {
                return(this);
            }

            //不存在条件,则加入
            orderList.Add(order);

            return(this);
        }
示例#7
0
 /// <summary>
 /// 进行OrderBy操作
 /// </summary>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public QuerySection <T> OrderBy(OrderByClip orderBy)
 {
     return(query.OrderBy(orderBy));
 }
示例#8
0
 /// <summary>
 /// 进行OrderBy操作
 /// </summary>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public QuerySection <T> OrderBy(OrderByClip orderBy)
 {
     this.orderBy = orderBy;
     return(this);
 }
示例#9
0
 /// <summary>
 /// 分页 返回Datatable
 /// </summary>
 /// <param name="currentPageindex"></param>
 /// <param name="pageSize"></param>
 /// <param name="where"></param>
 /// <param name="orderby"></param>
 /// <param name="record">总记录</param>
 /// <param name="fields"></param>
 /// <returns></returns>
 public virtual DataTable Get_Entity_byPage_ToTable(int currentPageindex, int pageSize,
                                                    WhereClip where, OrderByClip orderby, out int record, params Field[] fields)
 {
     record = Get_Entity_Record(where);
     return(Get_Entity_byPage_ToTable(currentPageindex, pageSize, where, orderby, fields));
 }
示例#10
0
 /// <summary>
 /// 进行排序操作
 /// </summary>
 /// <param name="orderBy"></param>
 /// <returns></returns>
 public TableRelation <T> OrderBy(OrderByClip orderBy)
 {
     section.OrderBy(orderBy);
     return(this);
 }
示例#11
0
 /// <summary>
 /// 返回最终排序的SQL
 /// </summary>
 /// <param name="order"></param>
 /// <returns></returns>
 public string Serialization(OrderByClip order)
 {
     return(dbProvider.FormatCommandText(order.ToString()));
 }
示例#12
0
 /// <summary>
 /// 返回最终排序的SQL
 /// </summary>
 /// <param name="order"></param>
 /// <returns></returns>
 public string Serialization(OrderByClip order)
 {
     return(dbProvider.Serialization(order.ToString()));
 }