Dao/Page/PageHelper.cs
(开头部分) 10KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Common;
using PWMIS.DataMap.Entity;
using PWMIS.DataProvider.Adapter;
using PWMIS.DataProvider.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Dao.Page
{
/// <summary>
/// 分页通用方法 Hugh.Long 2016.04.14
/// </summary>
/// <typeparam name="T"></typeparam>
public static class PageHelper<T> where T :class,new()
{
/// <summary>
/// 获取分页数据
/// </summary>
/// <param name="PageSize">显示页数</param>
/// <param name="PageNumber">当前页</param>
/// <param name="StrSql">SQL语句 无需加order by 否则会报错</param>
/// <param name="PageCount">总数</param>
/// <param name="OrderFiled">排序字段</param>
/// <returns>List<T></returns>
public static IList<T> GetPageListModel(int PageSize, int PageNumber, string StrSql, string OrderFiled, out int PageCount)
{
//DataSet dt=null;
try
{
//AdoHelper helper =MyDB.GetDBHelper(); //可直接写SQL语句
PageCount = GetPageCount(StrSql);
string sql = "SELECT TOP {0} * FROM (SELECT ROW_NUMBER() OVER (ORDER BY {1} desc) AS RowNumber,* FROM ({2}) as lt) A WHERE RowNumber > {3}*({4}-1)";
sql = string.Format(sql, PageSize, OrderFiled, StrSql, PageSize, PageNumber);
return EntityQuery.QueryList<T>(sql, null);
//dt = helper.ExecuteDataSet(SysConfig.DBConfig, System.Data.CommandType.Text,sql);
}
catch {
throw new Exception("执行语句报错");
}
//return DataSetPageToList<T>(dt, 0);
}
/// <summary>
/// 把IdataReader转车Model
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
public static T DoTransferType(IDataReader dr)
{
T model = new T();
try
{
int count = dr.FieldCount;
PropertyInfo[] property_lst = model.GetType().GetProperties();
foreach (PropertyInfo property in property_lst)
后面还有 212 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
