/// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <param name="selectSql"></param>
        /// <returns></returns>
        public static List <T> SkipTake <T>(this WhereHelperBase t, long skip, long take, string selectSql = null)
        {
            t.setCache();
            var sql = getSelect <T>(t, selectSql);

            return(t._sqlhelper.SkipTake <T>(skip, take, t.GetFullSelectSql(sql), t._args.ToArray()));
        }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="page"></param>
        /// <param name="itemsPerPage"></param>
        /// <param name="selectSql"></param>
        /// <returns></returns>
        public static Page <T> Page <T>(this WhereHelperBase t, long page, long itemsPerPage, string selectSql = null)
        {
            t.setCache();
            var sql = getSelect <T>(t, selectSql);

            return(t._sqlhelper.Page <T>(page, itemsPerPage, t.GetFullSelectSql(sql), t._args.ToArray()));
        }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="selectSql"></param>
        /// <returns></returns>
        public static T FirstOrDefault <T>(this WhereHelperBase t, string selectSql = null)
        {
            t.setCache();
            var sql = getSelect <T>(t, selectSql);

            return(t._sqlhelper.FirstOrDefault <T>(t.GetFullSelectSql(sql), t._args.ToArray()));
        }
 private static string getSelect <T>(WhereHelperBase t, string selectSql)
 {
     if (string.IsNullOrEmpty(selectSql) == false)
     {
         if (selectSql.StartsWith("Select", StringComparison.CurrentCultureIgnoreCase))
         {
             return(selectSql);
         }
         return("SELECT " + selectSql);
     }
     return(SelectHelper.CreateSelectHeader(typeof(T), t._headers, t.GetTypes()));
 }
 /// <summary>
 /// 执行返回DataSet
 /// </summary>
 /// <param name="t"></param>
 /// <param name="selectSql"></param>
 /// <returns></returns>
 public static DataSet ExecuteDataSet(this WhereHelperBase t, string selectSql = null)
 {
     t.setCache();
     return(t._sqlhelper.ExecuteDataSet(t.GetFullSelectSql(selectSql), t._args.ToArray()));
 }
        //public static T UseCache<T>(this T t, int second, string cacheTag, ICacheService cacheService) where T : IUseCache
        //{
        //    t.useCache(second, cacheTag, cacheService);
        //    return t;
        //}

        #endregion UseCache 设置缓存
        /// <summary>
        /// 获取数量
        /// </summary>
        /// <param name="t"></param>
        /// <param name="selectSql"></param>
        /// <returns></returns>
        public static int Count(this WhereHelperBase t, string selectSql = null)
        {
            t.setCache();
            return(t._sqlhelper.getDatabase(ConnectionType.Read).Execute(t.GetCountSql(selectSql), t._args.ToArray()));
        }