62,040
社区成员
发帖
与我相关
我的任务
分享
public class PagerTestIList<T>
{
static SqlDataReader dr = null;
static int count;
/// <summary>
/// 带参构造 通过传递参数调用存储过程
/// </summary>
/// <param name="table">表名</param>
/// <param name="where">查询子句</param>
/// <param name="order">排序</param>
/// <param name="blCount">状态</param>
/// <param name="p">分页实体类</param>
public PagerTestIList(string table, string where, string order, bool blCount, KFS_Model.Pager p)
{
SqlParameter[] parm ={
new SqlParameter("@table",SqlDbType.NVarChar),
new SqlParameter("@where",SqlDbType.NVarChar),
new SqlParameter("@order",SqlDbType.NVarChar),
new SqlParameter("@docount",SqlDbType.Bit),
new SqlParameter("@startIndex",SqlDbType.Int),
new SqlParameter("@endIndex",SqlDbType.Int)
};
parm[0].Value = table;
parm[1].Value = where;
parm[2].Value = order;
parm[4].Value = p.StartPager;
parm[5].Value = p.EndPager;
if (blCount)
{
parm[3].Value = 1;
dr = SqlHelper.ExecuteReader(SqlHelper.connectionString, CommandType.StoredProcedure, "QAS_pagination", parm);
if (dr.Read())
{
count = Convert.ToInt32(dr["Row"].ToString());
}
}
else
{
parm[3].Value = 0;
dr = SqlHelper.ExecuteReader(SqlHelper.connectionString, CommandType.StoredProcedure, "QAS_pagination", parm);
}
}
/// <summary>
/// 返回查询总条数
/// </summary>
/// <returns>int</returns>
public static int GetRecordCount()
{
return count;
}
/// <summary>
/// 通过反射机制返回查询的结果
/// </summary>
/// <returns>IList<T></returns>
public static IList<T> GetIlist()
{
IList<T> list = new List<T>();
T t = null;
PropertyInfo[] p=t.GetType().GetProperties();
while (dr.Read())
{
//取得所有属性
foreach (PropertyInfo pi in p)
{
t+"."+pi.Name;
pi.PropertyType;
}
}
}
}
public static IList<SqlDataReader > GetIlist()
{
IList<SqlDataReader > list = new List<SqlDataReader >();
SqlDataReader t = null;
PropertyInfo[] p=t.GetType().GetProperties();
while (dr.Read())
{
//取得所有属性
foreach (PropertyInfo pi in p)
{
t+"."+pi.Name;
pi.PropertyType;
}
}
}