Par*_*igm 2 c# sql linq asp.net
我正在尝试对dropdownlist进行排序,只是在选择了特定的id时才将其输入到数据库中.否则我希望它们按升序排序.我不确定如何在选择特定Id时添加不对列表进行排序的最终组件.这是我到目前为止的地方:
var items = (from p in _db.Funds
where p.DesignationId == id
orderby p.Name ascending
select new { p.id, p.Name });
return items;
Run Code Online (Sandbox Code Playgroud)
你的意思是这样的?
var items =
(from p in _db.Funds
where p.DesignationId == id
select new { p.id, p.Name });
if (id != "some id")
{
items = items.OrderBy(p => p.Name);
}
return items.ToList();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17568 次 |
| 最近记录: |