/// <summary>
        /// Gets the total for paging.
        /// </summary>
        /// <returns>System.Int32.</returns>
        /// <remarks>
        ///     <para>创建:Teddy</para>
        ///     <para>日期:2018/3/22</para>
        /// </remarks>
        public int GetTotalForPaging()
        {
            var where     = this.whereClip.Clone() as WhereClip;
            where.OrderBy = string.Empty;

            var result = new SelectSqlSection <T, TSchema>(db, table, where, table.Count).ToScalar();

            return(result is int?(int)result : int.Parse(result.ToString()));
        }
Esempio n. 2
0
        /// <summary>
        /// 按照条件分页获取数据
        /// </summary>
        /// <param name="sIndex">获取几条数据</param>
        /// <param name="eIndex">跳过几条数据</param>
        /// <param name="whereExp">条件: lambda表达式 如 : p=> p.Name =="2"  或者 p=> p.Name=="2" && p.ID ==1</param>
        /// <param name="orderExp">排序字段:lambda表达式 如 : p=> p.Name.Asc 或者 p=>p.Name.Desc</param>
        /// <returns></returns>
        /// <remarks>
        ///     [QueryTable].GetRangeDatas(10, 20, out recordCount, p=>p.Name=="aa", p=>p.ID);
        /// </remarks>
        public List <T> GetRangeDatas(int takeCount, int skipCount, out int recordCount, Func <TableSchema, WhereClip> whereExp, Func <TableSchema, OrderByClip> orderExp)
        {
            var session = new SelectSqlSection <T>(dataContext, Schema, Schema.All)
                          .Where(whereExp(Schema));

            recordCount = session.GetTotalForPaging();

            return(session.SetSelectRange(takeCount, skipCount)
                   .OrderBy(orderExp(Schema))
                   .ToList());
        }