3
我有DB命令,由2個表:不要屬性
**Job**
job_id (int, primary key),
job_nm (nchar(50))
**Employee**
empl_id (int, primary key)
job_id (int, forein key) (one-to-many)
first_name (nchar(50))
last_name (nchar(50))
salary (float)
I輸出由頁表(5行逐頁)。 它實現:
ViewBag.Tab = (from employee in db.Employees
join job in db.Jobs on employee.job_id equals job.job_id
where job.job_nm == sel1
orderby employee.salary
select employee
).Skip(pageSize * pageNum)
.Take(pageSize)
.ToList();
但我已經通過「工資」 - 場列表未排序。
我試過這段代碼:
ViewBag.Tab = (from employee in db.Employees
join job in db.Jobs
on employee.job_id equals job.job_id
where job.job_nm == sel1
orderby employee.salary
select employee
).Skip(pageSize * pageNum)
.Take(pageSize)
.ToList()
.OrderBy(s => s.salary);
,但還沒有結果。
我做錯了什麼?
我想這一點,但它並沒有排序「工資」 :( –
導致我注意到你已經在你的查詢有一個訂單,如果你拿出排序依據的LINQ聲明,這有幫助嗎? – brimble2010