在LINQ中将IGrouping转换为IQueryable

时间:2019-06-28 14:04:26

标签: c# linq igrouping

if (model.ConnectedToOtherProfilesId != 0)
{
      var fooGroup = fans.GroupBy(x => x.FanId)
                         .Where(x => x.Any(z => z.ProfileId == model.ConnectedToOtherProfilesId));

      var fooGroup2 = fooGroup.Where(grp => grp.Count() > 1);
}

我需要将fooGroup2 [IQueryable<IGrouping<int,PF>]的结果放入IQueryiable<PF>的粉丝中

类似这样的东西:

fans = fooGroup2;

1 个答案:

答案 0 :(得分:1)

您可以使用SelectMany

//IQueryable<PF>
var fooGroup2 = fooGroup.Where(grp => grp.Count() > 1)
                        .SelectMany(pf => pf);