public List <TWorkerEntity> GetWorkerInfoListByQueryModel(WorkerQuery workerQuery) { var mResult = new List <TWorkerEntity>(); using (IDbConnection conn = new SqlConnection(GetConnstr)) { StringBuilder strSql = new StringBuilder("Select * from tWorker where 1=1 "); if (!string.IsNullOrWhiteSpace(workerQuery.keyWords)) { strSql.Append(" and (WName=@keyWords or WNo=@keyWords or WDescript = @keyWords) "); } var param = new { keyWords = workerQuery.keyWords }; mResult = conn.Query <TWorkerEntity>(strSql.ToString(), param).ToList(); if (mResult != null) { mResult.ForEach(t => { var workerLines = new List <TWorkerLineEntity>(); var str = "select * from tWorkerLine where WId=@WId"; var wlparam = new { WId = t.WId }; workerLines = conn.Query <TWorkerLineEntity>(str, wlparam).ToList(); t.LineList = workerLines; }); } } return(mResult); }
public List <TWorkerEntity> GetWorkerInfoListByQueryModel(WorkerQuery workerQuery) { var mResult = new List <TWorkerEntity>(); using (IDbConnection conn = new SqlConnection(GetConnstr)) { StringBuilder strSql = new StringBuilder("Select * from tWorker where 1=1 "); if (!string.IsNullOrWhiteSpace(workerQuery.keyWords)) { strSql.Append(" and (WName=@keyWords or WNo=@keyWords or WDescript = @keyWords) "); } var param = new { keyWords = workerQuery.keyWords }; mResult = conn.Query <TWorkerEntity>(strSql.ToString(), param).ToList(); } return(mResult); }
public ActionResult WorkerListResult(WorkerQuery workerQuery) { var workerList = tWorkerRepository.GetWorkerInfoListByQueryModel(workerQuery); return(View(workerList)); }