我想根据结果订购一个列表
if(group.Substring(group.Length-1,1)%2==0)
降序
else
升序
List<CellTemp> orderedCells =
(from shelf in foundCells
where Convert.ToInt32(shelf.Group.Substring(shelf.Group.Length - 1), 1) % 2 == 0
orderby shelf.Grup, shelf.Row descending
select new CellTemp()
{
cod= shelf.cod,
PN = shelf.PN,
Description = shelf.Description,
Group= shelf.Group,
Row= shelf.Row,
Shelf= shelf.Shelf
}).ToList();
我怎样才能保持第一个shelf.Group OrderBy 和OrderBy Shelf.row 升序或降序取决于shelf.Group 是奇数还是偶数?
Shelf.group 的格式是“Group_A0”。
--------------------编辑---------------
对困惑感到抱歉。我想做这样的事情。
var orderCells = (from shelf in celuleGasite
where Convert.ToInt32(shelf.Gruup.Substring(shelf.Group.Length - 1, 1)) % 2 == 0
orderby shelf.Group, shelf.Row descending
where Convert.ToInt32(shelf.Group.Substring(shelf.Group.Length - 1, 1)) % 2 == 1
orderby shelf.Group, shelf.Row ascending
select shelf).ToList();
但列表有 0 个元素