/// <summary> /// 指定格式化返回单个结果[基本方法] /// </summary> /// <param name="sql"></param> /// <param name="parame"></param> /// <param name="types"></param> /// <returns></returns> protected T ExecScalarWithFormat <T>(string sql, ParameCollection parame, params Type[] types) { DBExtend helper = dbHelper; foreach (var p in parame) { helper.AddParam(p.Key, p.Value); } return(helper.ExecScalar <T>(sql, types)); }
/// <summary> /// 指定格式化查询列表[基本方法] /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sql"></param> /// <param name="parame"></param> /// <param name="types"></param> /// <returns></returns> protected List <T> ExecListWithFormat <T>(string sql, ParameCollection parame, params Type[] types) where T : class, new() { DBExtend helper = dbHelper; foreach (var p in parame) { helper.AddParam(p.Key, p.Value); } return(helper.ExecList <T>(sql, types)); }
/// <summary> /// 指定格式化更新[基本方法] /// </summary> /// <param name="sql"></param> /// <param name="parame"></param> /// <param name="types"></param> /// <returns></returns> protected static int ExecuteWithFormat(string sql, ParameCollection parame, params Type[] types) { DBExtend helper = dbHelper; foreach (var p in parame) { helper.AddParam(p.Key, p.Value); } return(helper.Execute(sql, types)); }
/// <summary> /// 对GROUP进行分页 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="query">查询 如:ProductReceiptDetail with (nolock) group by styleid</param> /// <param name="fields">查询字段 如:styleid,sum(num) as total</param> /// <param name="rowOver">行排序 如:sum(num) desc</param> /// <param name="sortfield">排序字段 如:total desc</param> /// <param name="pageSize">每页大小</param> /// <param name="pageIndex">页索引</param> /// <param name="count"></param> /// <returns></returns> protected static List <T> GroupByPage <T>(string query, string fields, string rowOver, string sortfield, int pageSize, int pageIndex, out int count) where T : class, new() { count = 0; DBExtend helper = dbHelper; helper.AddParam("query", query); helper.AddParam("fields", fields); helper.AddParam("rowOver", rowOver); helper.AddParam("sortfield", sortfield); helper.AddParam("pageSize", pageSize); helper.AddParam("pageIndex", pageIndex); helper.AddOutParam("Counts"); var list = helper.RunList <T>("sp_GroupPage"); count = Convert.ToInt32(helper.GetOutParam("Counts")); return(list); }