SQLページング、行レコードの検索、C#ASP.NETページング方法


SQL文:
select * from
(select ROW_NUMBER() over(order by @    ) as rowNum,      from Expend where   ) as tab where 
rowNum>=@   and rowNum<=@  

C#コード:
         /// <summary>
        ///       
         /// </summary>
        /// <typeparam name="T">Domain  </typeparam>
        /// <param name="selectView">    (  ,  )</param>
        /// <param name="field">    </param>
        /// <param name="whereSQL">    (  where   )</param>
        /// <param name="orderSQL">    (  ,  )</param>
        /// <param name="start">     ( 0  ,    start    )</param>
        /// <param name="limit">     </param>
        /// <returns></returns>
        public List<T> QueryPageList<T>(string selectView,string field, string whereSQL , string orderSQL, int start, int limit) where T : IDomainObject, new()
        {
            List<T> _ret = new List<T>();

            if (string.IsNullOrEmpty(field)) field = "*";
            if (string.IsNullOrEmpty(whereSQL)) whereSQL = " 1=1 ";
            whereSQL = whereSQL.Replace("where", "");

            string sql = "select * from(";
            sql += " select ROW_NUMBER() over(ORDER BY {0}) as RowNumber,{1} from {2} where {3}";
            sql += " ) as tab where RowNumber>{4} and RowNumber<={5}";
            sql = string.Format(sql, orderSQL, field, selectView, whereSQL, start, limit);

            _ret = QueryForList<T>(sql, null);

            return _ret;
        }