我很好奇aa linq group by 子句中的x是什么意思: group x by ...
x 可以用 1 代替:
var query = from box in c.Boxes
join item in c.Items on box equals item.Box
group 1 by new { BoxId = box.BoxId, item.ItemType.ItemTypeId } into g
select new { g.Key.BoxId, g.Key.ItemTypeId, Count = g.Count() };
有没有人有一个样本,其中 x (或您在 group by 中选择的任何局部变量)确实具有一定的价值?
我是说
var query2 = from box in c.Boxes
group box by box.BoxId into q
select q.Key;
可以替换为
var query2 = from box in c.Boxes
group 1 by box.BoxId into q
select q.Key;