0

我正在尝试将以下代码转换为 lambda 样式,但没有成功。

DiscCurrentLocation[] old =
  (from v in volumeDC.Volumes
   join d in volumeDC.Disc_Vs
     on v.VolumeID equals d.DiscVolumeID
   group d by new { v.VolumeLibID, d.DiscCurrentLocation } into g
   where (g.Key.VolumeLibID == libraryId && g.Key.DiscCurrentLocation > -1
     && g.Count() > 1)
   select (DiscCurrentLocation)g.Key.DiscCurrentLocation
  ).ToArray<DiscCurrentLocation>();

有人可以告诉我如何转换它吗?谢谢

4

1 回答 1

3

这应该是相同的:

DiscCurrentLocation[] old = volumeDC.Volumes
  .Join(volumeDC.Disc_Vs, (v) => v.VolumeID, (d) => d.DiscVolumeID,
      (v, d) => new { Volume = v, Disc_V = d })
  .GroupBy(vd => new { vd.Volume.VolumeLibID, vd.Disc_V.DiscCurrentLocation })
  .Where (grp => grp.Key.VolumeLibID == libraryId
      && grp.Key.DiscCurrentLocation > -1 && grp.Count() > 1)
  .Select (grp => (DiscCurrentLocation)grp.Key.DiscCurrentLocation)
  .ToArray<DiscCurrentLocation>()
;
于 2012-11-20T18:52:32.637 回答