public IEnumerable <sys_organize> List(organizeparm parm, out int recordcount) { DynamicParameters p = new DynamicParameters(); StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM dbo.sys_organize WHERE 1=1"); if (!string.IsNullOrEmpty(parm.code)) { sql.Append(" and code like @code "); p.Add("code", '%' + parm.code + '%'); } if (!string.IsNullOrEmpty(parm.key)) { sql.Append(" and title like @key "); p.Add("key", '%' + parm.key + '%'); } if (!string.IsNullOrEmpty(parm.pid)) { sql.Append(" and pid = @pid "); p.Add("pid", parm.pid); } using (LocalDB db = new LocalDB()) { var list = db.Current_Conn.Query <sys_organize>(sql.ToString(), p).OrderByDescending(t => t.id).ToPagedList(parm.pageindex, parm.pagesize); recordcount = list.TotalItemCount; return(list); } }
public IHttpActionResult List(organizeparm parm) { try { int recordcount = 0; OrganizeService os = new OrganizeService(); var list = os.List(parm, out recordcount); return(Json(new { code = 1, msg = "ok", list = list, recordcount = recordcount })); } catch (Exception e) { return(Json(new { code = 0, msg = e.Message })); } }